subject 1: Yes 1,2,3,4 Number , How many different three digit numbers can be composed without repetition ? How many are they ?
#include<stdio.h> int main() { int ge = 0, shi = 0, bai = 0, i = 0; int count =
0; int a[100] = {0}; for(ge = 1; ge < 5; ge++) { for(shi = 1; shi < 5; shi++) {
if(shi == ge) // Exclude the equality of tens and ones { continue; } for(bai = 1; bai < 5; bai++) { if(bai ==
shi|| bai == ge) // Exclude bits equal to tens or hundreds equal to ones { continue; } a[count] = bai * 100 + shi *
10 + ge; count++; } } } printf("1,2,3,4 It can be composed of three digits which are different from each other and have no repetition %d individual \n", count); printf(
" namely "); for(i = 0; i < count; i++) { printf("%d ", a[i]); } printf("\n"); return
0; }
Operation results

subject 2: Bonus paid by the enterprise is based on profit commission .
profit (I) Less than or equal to 10 Ten thousand yuan per hour , Bonus can be withdrawn 10%;
Profit is higher than 10 10000 yuan , lower than 20 Ten thousand yuan per hour , lower than 10 Part of ten thousand yuan 10% Commission , higher than 10 Part of ten thousand yuan , Royalty 7.5%;
20 Ten thousand to 40 10000 hours , higher than 20 Part of ten thousand yuan , Royalty 5%;
40 Ten thousand to 60 Higher than 10000 hours 40 Part of ten thousand yuan , Royalty 3%;
60 Ten thousand to 100 10000 hours , higher than 60 Part of ten thousand yuan , Royalty 1.5%,
higher than 100 Ten thousand yuan per hour , exceed 100 Part of ten thousand yuan 1% Commission ,
Enter current month profit from keyboard I, Total bonus payable ?
#include<stdio.h> int main() { double profit = 0, bonus = 0, bonus1 = 0, bonus2
= 0, bonus3 = 0, bonus4 = 0, bonus5 = 0; bonus1 = 100000 * 0.1; bonus2 = (200000
- 100000) * 0.075 + bonus1; bonus3 = (400000 - 200000) * 0.05 + bonus2; bonus4 =
(600000 - 400000) * 0.03 + bonus3; bonus5 = (1000000 - 600000) * 0.015 + bonus4;
printf(" Please enter the profit of the current month :"); scanf("%lf", &profit); if(profit < 100000) { bonus = profit
* 0.1; } else if(profit < 200000) { bonus = (profit - 100000) * 0.075 + bonus1;
} else if(profit < 400000) { bonus = (profit - 200000) * 0.05 + bonus2; } else
if(profit < 600000) { bonus = (profit - 400000) * 0.03 + bonus3; } else if(
profit< 1000000) { bonus = (profit - 600000) * 0.015 + bonus4; } else { bonus =
(profit - 1000000) * 0.01 + bonus5; } printf(" Total bonus payable %.2f\n", bonus); return 0;
}
Operation results

subject 3: An integer , It adds 100 And then there's a complete square , Plus 168 It's a complete square again , What's the number, please ?
#include<stdio.h> #include<math.h> int GetPs(int a) { if(sqrt(a) == ((int)sqrt(
a))) { return 1; } return 0; } // Find the matching integer according to the input range int FindNumber(int len) { int i =
0; for(i = 0; i < len; i++) { // Match an integer plus 100 Plus 168 And then they're all square numbers if((GetPs(i + 100))&&(
GetPs(i + 268))) return i; } } int main() { printf(" This number is %d\n", FindNumber(10000)
); return 0; }
Operation results

subject 4: Enter month day of year , Judge the day as the day of the year ?
#include<stdio.h> // Get the number of days according to MM DD YY int GetNum(int year, int mouth, int day) { int a
= 0; switch(mouth) { case 1: a = day; break; case 2: a = day + 31; break; case 3
: a = day + 31 + 28; break; case 4: a = day + 31 * 2 + 28; break; case 5: a =
day+ 31 * 2 + 28 + 30; break; case 6: a = day + 31 * 3 + 28 + 30; break; case 7:
a= day + 31 * 3 + 28 + 30 * 2; break; case 8: a = day + 31 * 4 + 28 + 30 * 2;
break; case 9: a = day + 31 * 5 + 28 + 30 * 2; break; case 10: a = day + 31 * 5
+ 28 + 30 * 3; break; case 11: a = day + 31 * 6 + 28 + 30 * 3; break; case 12: a
= day + 31 * 6 + 28 + 30 * 4; break; default: ; } if((year % 4 == 0)&&(year %
100 != 0)||(year % 400 == 0)) { if (mouth > 2) { a = a + 1; } } return a; } int
main() { int year = 0, mouth = 0, day = 0; int num = 0; printf(" Please enter date ( as 1970 1
1):"); scanf("%d %d %d", &year, &mouth, &day); if((mouth > 12)||(mouth < 1)) {
printf(" Input month error \n"); return -1; } else if((mouth == 1)||(mouth == 3)||(mouth == 5
)||(mouth == 7)||(mouth == 8)||(mouth == 10)||(mouth == 12)) { if(day > 31) {
printf(" Input date exceeds the maximum number of days of this month \n"); return -1; } else { num = GetNum(year, mouth, day); }
} else if((mouth == 4)||(mouth == 6)||(mouth == 9)||(mouth == 11)) { if(day > 30
) { printf(" Input date exceeds the maximum number of days of this month \n"); return -1; } else { num = GetNum(year, mouth, day)
; } } else { if((year % 4 == 0)&&(year % 100 != 0)||(year % 400 == 0)) { if(day
> 29) { printf(" Input date exceeds the maximum number of days of this month \n"); return -1; } else { num = GetNum(year, mouth,
day); } } else { if(day > 28) { printf(" Input date exceeds the maximum number of days of this month \n"); return -1; } else {
num= GetNum(year, mouth, day); } } } printf(" This is the first day of the year %d day \n", num); return 0; }
Operation results

subject 5: Enter three integers x,y,z, Please output these three numbers from small to large .
#include<stdio.h> int main() { int x = 0, y = 0, z = 0; int temp = 0; printf(
" Please enter three integers ( as 1 2 3):"); scanf("%d %d %d", &x, &y, &z); if(x > y) { temp = x; x = y;
y= temp; } if(x > z) { temp = x; x = z; z = temp; } if(y > z) { temp = y; y = z
; z = temp; } printf(" The order from small to large is :%d < %d < %d\n", x, y, z); return 0; }
Operation results

subject 6: use * No. output letter C Pattern of
#include<stdio.h> int main() { printf("****\n"); printf("*\n"); printf("*\n");
printf("****\n"); return 0; }
Operation results

subject 7: Output special pattern , Please visit c Run in environment , have a look ,Very Beautiful!
ASCII code , decimal system 0~126 Displayable , greater than 126 Display Chinese characters when
attach :ASCII Code comparison table

#include<stdio.h> int main() { char a = 3, b = 2; printf("%c%c%c%c%c\n", b, a,
a, a, b); printf("%c%c%c%c%c\n", a, b, a, b, a); printf("%c%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%c\n", b, a, a, a
, b); return 0; }
Operation results

subject 8: output 9*9 Pithy formula
#include<stdio.h> int main() { int i = 0, j = 0; for(i = 1; i < 10; i++) { for(
j= 1; j <= i; j++) { printf("%d*%d=%d ", i, j, i * j); } printf("\n"); } return
0; }
Operation results

subject 9: Chess board output required .
#include<stdio.h> int main() { int i = 0, j = 0; for(i = 0; i < 8; i++) { for(j
= 0; j < 8; j++) { if((i + j) % 2 == 0) { printf("%c%c", '\xA1', '\xF6'); }
printf(" "); } printf("\n"); } return 0; }
Operation results

subject 10: Printing stairs , Print two smiley faces at the same time above the stairs
#include<stdio.h> int main() { int i = 0, j = 0; printf("%c%c\n", 1, 1); for(i
= 1; i < 10; i++) { for(j = 1; j <= i; j++) { printf("%c%c", 168, 128); } printf
("\n"); } return 0; }
Operation results

subject 11: Fibonacci sequence algorithm [1,1,2,3,5,8,13,21……]
Classical problems : There is a pair of rabbits , After birth 3 A couple of rabbits every month since ,
After the third month, the little rabbit will have another pair of rabbits every month , If the rabbit doesn't die , What is the total number of rabbits per month ?
#include<stdio.h> int main() { int shu_zi = 0, shu_zi_1 = 1, shu_zi_2 = 1,
xun_huan= 0; printf(" Please enter the number :"); scanf("%d", &shu_zi); if(shu_zi <= 1) { printf(
" The result is 1\n"); } else { for(xun_huan = 2; xun_huan <= shu_zi; xun_huan ++) { int shu
= shu_zi_1 + shu_zi_2; shu_zi_1 = shu_zi_2; shu_zi_2 = shu; } printf(" The result is %d\n",
shu_zi_2); } return 0; }
Operation results

#include<stdio.h> int f(int shu_zi) { if(shu_zi <= 1) { return 1; } else {
return f(shu_zi - 2) + f(shu_zi - 1); } } int main() { int shu_zi = 0, shu_zi_1
= 1, shu_zi_2 = 1, xun_huan = 0; printf(" Please enter the number :"); scanf("%d", &shu_zi);
printf(" The result is %d\n", f(shu_zi)); return 0; }
Operation results

#include<stdio.h> int shu[100] = {1, 1}; int f(int shu_zi) { //int shu[100] =
{1, 1}; if(!shu[shu_zi]) { return f(shu_zi - 2) + f(shu_zi - 1); } else { return
shu[shu_zi]; } } int main() { int shu_zi = 0, shu_zi_1 = 1, shu_zi_2 = 1,
xun_huan= 0; printf(" Please enter the number :"); scanf("%d", &shu_zi); printf(" The result is %d\n", f(
shu_zi)); return 0; }
Operation results

#include<stdio.h> int shu[100] = {1, 1}; // global variable int f(int shu_zi) { //int
shu[100] = {1, 1}; // local variable if(!shu[shu_zi]) { shu[shu_zi] = f(shu_zi - 2) + f(
shu_zi- 1); return shu[shu_zi]; } else { return shu[shu_zi]; } } int main() {
int shu_zi = 0; printf(" Please enter the number :"); scanf("%d", &shu_zi); printf(" The result is %d\n", f(
shu_zi)); return 0; }
Operation results

#include<stdio.h> int main() { int a = 1, b = 1, i = 0; for(i = 1; i <= 10; i++
) // Before output sequence 20 term { printf("%d %d ", a, b); a = a + b; b = b + a; } printf("\n");
return 0; }
Operation results

subject 12: judge 101~200 How many primes are there between , And output all prime numbers
#include<stdio.h> #include<math.h> int main() { int i = 0, j = 0, k = 0, count
= 0, flag = 1; for(i = 101; i <= 200; i += 2) // Because even numbers must not be prime numbers , In steps of 2 More efficient { k = (int)
sqrt(i); for(j = 2; j <= k; j++)// Only in 2 To the root i Find factor between { if(i % j == 0) { flag = 0;
// use flag Tag all , If a factor is found , take flag Assigned as 0 } } if(flag != 0) { printf("%d ", i); count++; if(
count% 5 == 0) { printf("\n"); } } flag = 1; // Before the next cycle starts flag Reset } printf("\n");
printf("101~200 There are %d Prime number \n", count); return 0; }
Operation results

/* * date :2020 year 4 month 8 day * subject : Find out whether a number is prime * input : nothing * output : */ #include <stdio.h> #include
<math.h> int main() { int xunhuan = 0; int gen = 0; int shuzi = 0; printf(
" Please enter a number :"); scanf("%d", &shuzi); gen = sqrt(shuzi); for(xunhuan = 2; xunhuan <
gen; xunhuan++) { if(!(shuzi % xunhuan)) break; } if (xunhuan <= gen) { printf(
"%d Not prime \n", shuzi); } else { printf("%d Is prime number \n", shuzi); } return 0; }
Operation results

subject 13: Print out all “ Narcissistic number ”, so-called “ Narcissistic number ” A three digit number , The sum of the cubes of its digits is equal to this number
    itself . for example :153 It's a “ Narcissistic number ”, because 153=1 Third power of +5 Third power of +3 Third power of
#include<stdio.h> #include<math.h> int main() { int i = 0, ge = 0, shi = 0, bai
= 0; printf(" Please output all daffodils :\n"); for(i = 100; i < 1000; i++) { bai = i / 100; shi =
i/ 10 % 10; ge = i % 10; if(i == pow(bai, 3) + pow(shi, 3) + pow(ge, 3)) {
printf("%-4d", i); } } printf("\n"); return 0; }
Operation results

subject 14: Decomposing a positive integer into prime factors . for example : input 90, Print out 90=233*5.
/* * date :2020 year 4 month 14 day * subject : Decomposing a positive integer into prime factors . for example : input 90, Print out 90=2*3*3*5.
* analysis : Yes n To decompose the prime factor , We should find a minimum prime number first k, Then complete as follows : If this prime is exactly equal to n, It means that the process of decomposing prime factor is over , Just print out .
If n>k, but n Can be k to be divisible by , Should be printed out k Value of , Combined use n divide k The quotient of , As a new positive integer , Repeat step 1 . If n Can't be k to be divisible by , Then use k+1 As k Value of , Repeat step 1 .
* input : nothing * output : */ #include<stdio.h> int main() { int num = 0, i = 0; printf(
" Enter a positive integer :"); scanf("%d", &num); printf("%d = ", num); for(i = 2; i <= num; i++)
{ while(num != i) { if(num % i == 0) { printf("%d * ", i); num = num / i; } else
{ break; } } } printf("%d\n", num); return 0; }
Operation results

subject 15: Using nesting of conditional operators to complete this problem : academic record >=90 For each student A express ,60-89 Use between points B express ,
   60 For the following purposes C express .
#include<stdio.h> int main() { int score = 0; char grade = 0; printf(" Please enter your academic record :"
); scanf("%d", &score); grade = (score >= 90) ? 'A' : ((score < 60) ? 'C' : 'B')
; printf("%d belong to %c\n", score, grade); return 0; }

subject 16: Enter two positive integers m and n, Find the greatest common divisor and the least common multiple .
#include<stdio.h> int main() { int m = 0, n = 0, a = 0,b = 0, temp = 0; printf(
" Please enter two positive integers :( as 100,50)"); scanf("%d,%d", &m, &n); a = m; b = n; if(m < n) { temp =
m; m = n; n = temp; } for(temp = m % n; temp != 0;) // Rolling phase division { m = n; n = temp;
temp= m % n; } printf(" The minimum common divisor is %d, The minimum common multiple is %d\n", n, a * b / n); return 0; }
Operation results

subject 17: Enter a line of characters , Count the Chinese and English letters respectively , Space , Number of numbers and other characters .
#include<stdio.h> int main() { char c = 0; int letter = 0, space = 0, digit = 0
, other = 0; printf(" Please enter a string :"); while((c = getchar()) != '\n') { if(((c >= 'a')
&&(c <= 'z'))||((c >= 'A')&&(c <= 'Z'))) { letter++; } else if(c == ' ') { space
++; } else if((c >= '0')&&(c <= '9')) { digit++; } else { other++; } } printf(
" There are letters in the string %d, Space %d, number %d, Other characters %d\n", letter, space, digit, other); return 0; }
Operation results

subject 18
: seek s=a+aa+aaa+aaaa+aa…a Value of , among a It's a number . for example 2+22+222+2222+22222( Now shared 5 Sum of numbers ), Keyboard control for adding several numbers .
#include<stdio.h> int main() { int a = 0, n = 0, count = 1; long int sn = 0, tn
= 0; printf(" Please enter a number and add several numbers ( as 2,5):"); scanf("%d,%d", &a, &n); while(count <= n) {
tn= tn + a; sn = sn + tn; a = a * 10; ++count; } printf("a+aa+aaa+……=%ld\n", sn)
; return 0; }
Operation results

subject 19: If a number is exactly equal to the sum of its factors , This number is called “ perfect number ”. for example 6=1+2+3. programming , find 1000 All completions within .
#include<stdio.h> int main() { int i = 0, j = 0, sum = 0; for(i = 1; i <= 1000;
i++) { for(j = 1;j < i; j++) { if(i % j == 0) { sum = sum + j; // Work out the sum of all factors } }
if(sum == i) { printf("%d ", i); } sum = 0; // Reset sum } printf("\n"); return 0; }
Operation results

subject 20: A ball from 100 Free fall at meter height , Jump back to half of the original altitude after each landing ; Fall again , Ask it in the 10 Secondary landing , How many meters in total ? The first 10 How high is the secondary bounce ?
#include<stdio.h> int main() { double sum = 100.0, h = sum / 2; //h For the height of each bounce int
i= 0; for(i = 2; i <= 10; i++) //sum,h Initial value is the first landing value ,i comply with 2 start { sum = sum + h * 2;
// The height of two rebounds between landing and rising h = h / 2; } printf(" The first 10 Secondary landing , Common course %f rice , The first 10 Height of secondary bounce %f\n", sum,
h); return 0; }
Operation results

Technology
©2019-2020 Toolsou All rights reserved,
el-ui:select Get value Hackbar Using the tutorial Online troubleshooting HTTP Status code ——415 and 406python read , write in txt Text content golang One line of code converts the slice into a semicolon separated string Map judge key Corresponding value Does the value exist -containsKey()css Basics 2:flex Multi row layout with gaps Golang Array bisection , Array split , Array grouping python primitive -- lock Lock415 Status code to background error