[Program 1]
Title: There are 1, 2, 3, 4 numbers, how many three digits that are different from each other and no repeated numbers? What is it?
1. Program analysis: Fill in hundreds, ten, and bit numbers are 1, 2, 3, 4. Composition all the arrangement and remove the arrangement of the conditions.
2. Program source code:
Main () {INT I, J, K; Printf ("/ n"); for (i = 1; i <5; i ) / * The following is a triple loop * / for (j = 1; j <5; J ) ) For (k = 1; k <5; k ) {if (i! = K && i! = J && j! = K) / * Make sure I, J, K three mutually different * / printf ("% d,% d) % d / n ", i, j, k);}}
[Program 2]
Title: The bonuses issued by the enterprise shall be submitted according to profit. When the profit (i) is less than or equal to 100,000 yuan, the bonus can be added 10%; the profit is higher than 100,000 yuan, less than 200,000 yuan, less than 100,000 yuan is added 10%, higher than 100,000 yuan. Part of the part, can be cocoa 7.5%; when 20,000 to 400,000, the part is higher than 200,000 yuan, it can be brought by 5%; between 400,000 and 600,000, it can be 3%. When 600,000 to 1 million, higher than 600,000 yuan, can be brought by 1.5%, higher than 1 million yuan, more than 1 million yuan, according to 1%, from the keyboard input the monthly profit I, seeking Total number of bonuses?
1. Program analysis: Please use the number axis to be bounded and positioned. Note that the bonus will be defined to grow.
2. Program source code:
Main () {Long Int i; Int Bonus1, Bonus2, Bonus4, Bonus6, Bonus10, Bonus; Scanf ("% ld", & i); bonus1 = 100000 * 0.1; bonus2 = Bonus1 100000 * 0.75; bonus4 = Bonus2 200000 * 0.5; bonus6 = BONUS4 200000 * 0.3; Bonus10 = BONUS6 400000 * 0.15; IF (i <= 100000) Bonus = i * 0.1; Else IF (i <= 200000) Bonus = Bonus1 (i-100000) * 0.075 ELSE IF (i <= 400000) BONUS = BONUS2 (I-200000) * 0.05; ELSE IF (i <= 600000) Bonus = Bonus4 (i-400000) * 0.03; Else IF (i <= 1000000) Bonus = Bonus6 (i-600000) * 0.015; Else Bonus = Bonus10 (i-1000000) * 0.01; Printf ("Bonus =% D", Bonus);} [Program 3]
Title: An integer, it plus 100 is a full level, plus 168 is a complete square number, how much is this?
1. Program analysis: Judgment within 100,000, first plus 100, then open, then add 268, then reappear, if the result is satisfied, that is, the result. Please see specific analysis:
2. Program source code:
#include "math.h" main () {long Int i, x, y, z; for (i = 1; i <100000; i ) {x = SQRT (i 100); / * x is plus 100 The result of the rear start * / y = SQRT (i 268); / * y is the result of the next 168 after the 1st 1 * / if (x * x == i 100 && y * y == i 268 ) / * If the square of the square root of a number is equal to this, this indicates that this is completely square * / printf ("/ n% ld / n", i);}}
[Program 4]
Topic: Enter a day in a certain year, judging this day is the first day of this year?
1. Program analysis: Take March 5 as an example, you should first add the first two months, then add 5 days, the first day, special circumstances, leap year, and enter the month to consider Add a day.
2. Program source code: main () {Int Day, month, year, sum, leap; printf ("/ nplease input year, month, day / n"); scanf ("% D,% D,% D", & Year, & Month, & Day); Switch (MONTH) / * First calculate the total number of days in the month * / {case 1: sum = 0; Break; Case 2: sum = 31; Break; Case 3: Sum = 59; Break; Case 4: Sum = 90; Break; Case 5: SUM = 120; Break; Case 6: Sum = 151; Break; Case 7: Sum = 181; Break; Case 8: Sum = 212; Break; Case 9: SUM = 243; Break; Case 10: Sum = 273; Break; Case 11: Sum = 304; Break; Case 12: Sum = 334; Break; Default: Printf ("Data Error"); Break;} Sum = SUM Day; / * plus a certain day * / if (Year% 400 == 0 || (Year% 4 == 0 && year% 100! = 0)) / * Judgment is a leap year * / leap = 1; ELSE Leap = 0; if (Leap == 1 && Month> 2) / * If it is a leap year, the month is greater than 2, the total number of days should add a day * / sum ; Printf ("IT is the% dth day.", sum.
[Program 5]
Title: Enter three integers x, y, z, please put these three numbers from small to large output.
1. Program analysis: We want to put the smallest number to the X, first compare X and Y, if X> Y swaps X and Y, then use x and z, if x > z Exchange X with the value of Z, which makes X minimizes.
2. Program source code:
Main () {Int x, y, z, t; scanf ("% D% D% D", & x, & y, & z); if (x> y) {t = x; x = y; y = t; } / * The value of X, Y * / if (x> z) {t = z; z = x; x = t;} / * swap x, z value * / if (y> z) {t = Y; y = z; z = t;} / * exchange z, y value * / printf ("Small to Big:% D% D% D / N", X, Y, Z);}
[Program 6]
Title: Output the pattern of the letter C with the *. 1. Program analysis: You can use the '*' number to write the letter C to the paper, and then the branch is output.
2. Program source code:
#include "stdio.h" main () {printf ("Hello C-World! / N"); Printf ("**** / n"); Printf ("* / n"); printf ("* / N "); Printf (" **** / n ");}
[Program 7]
Topic: Output special patterns, please run in the C environment, take a look, Very Beautiful!
1. Program analysis: 256 characters. Different characters, graphics are different.
2. Program source code:
#include "stdio.h" main () {char A = 176, b = 219; Printf ("% C% C% C% C / N", B, A, A, A, B); Printf "% C% C% C% C / N", A, B, A, B, A); Printf ("% C% C% C% C / N", A, A, B, A , a); Printf ("% C% C% C% C% C / N", A, B, A, B, A); Printf ("% C% C% C% C / N", B , A, A, B);
[Program 8]
Topic: Output 9 * 9 ok.
1. Program analysis: Branch and column considerations, a total of 9 rows, I control line, J control column.
2. Program source code:
#include "stdio.h" main () {INT I, J, Result; Printf ("/ n"); for (i = 1; i <10; i ) {for (j = 1; j <10; J {Result = i * j; printf ("% D *% D =% - 3D", i, j, result); / * - 3D means left alignment, accounting for 3 bits * /} printf ("/ n") ; / * Return after each line * /}}
[Program 9]
Title: Requires the output chess board.
1. Program analysis: Use the I control line, j to control the column, control the output black square according to the change in I J, or white square.
2. Program source code:
#include "stdio.h" main () {INT I, J; for (i = 0; i <8; i ) {for (j = 0; j <8; j ) IF ((i j)% 2 == 0) Printf ("% C% C", 219, 219); Else Printf (""); printf ("/ n");}} [program 10]
Topic: Print the stairs, and print two smiles above the stairs.
1. Program analysis: Use the I control line, j to control the column, and the number of output black signs according to the change of I.
2. Program source code:
#include "stdio.h" main () {INT I, J; Printf ("/ 1/1 / n"); / * Output two smile * / for (i = 1; i <11; i ) {for (j = 1; j <= i; j ) Printf ("% C% C", 219, 219); Printf ("/ n");}}