#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) //排除个位和十位相等 { continue; } for(bai = 1; bai < 5; bai++) { if(bai ==
shi|| bai == ge) //排除个位与十位相等或百位与个位相等 { continue; } a[count] = bai * 100 + shi *
10 + ge; count++; } } } printf("1,2,3,4可组成互不相同且无重复数字的三位数共%d个\n", count); printf(
"分别是"); for(i = 0; i < count; i++) { printf("%d ", a[i]); } printf("\n"); return
0; }

20万到40万之间时，高于20万元的部分，可提成5%；
40万到60万之间时高于40万元的部分，可提成3%；
60万到100万之间时，高于60万元的部分，可提成1.5%，

#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("请输入当月利润："); 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("应发放奖金总数%.2f\n", bonus); return 0;
}

#include<stdio.h> #include<math.h> int GetPs(int a) { if(sqrt(a) == ((int)sqrt(
a))) { return 1; } return 0; } //根据输入范围查找符合的整数 int FindNumber(int len) { int i =
0; for(i = 0; i < len; i++) { //符合一个整数加100再加168后都是完全平方数 if((GetPs(i + 100))&&(
GetPs(i + 268))) return i; } } int main() { printf("这个数是%d\n", FindNumber(10000)
); return 0; }

#include<stdio.h> //根据年月日获取天数 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("请输入年月日(如1970 1
1)："); scanf("%d %d %d", &year, &mouth, &day); if((mouth > 12)||(mouth < 1)) {
printf("输入月份错误\n"); return -1; } else if((mouth == 1)||(mouth == 3)||(mouth == 5
)||(mouth == 7)||(mouth == 8)||(mouth == 10)||(mouth == 12)) { if(day > 31) {
printf("输入日期超过本月最大天数\n"); return -1; } else { num = GetNum(year, mouth, day); }
} else if((mouth == 4)||(mouth == 6)||(mouth == 9)||(mouth == 11)) { if(day > 30
) { printf("输入日期超过本月最大天数\n"); return -1; } else { num = GetNum(year, mouth, day)
; } } else { if((year % 4 == 0)&&(year % 100 != 0)||(year % 400 == 0)) { if(day
> 29) { printf("输入日期超过本月最大天数\n"); return -1; } else { num = GetNum(year, mouth,
day); } } else { if(day > 28) { printf("输入日期超过本月最大天数\n"); return -1; } else {
num= GetNum(year, mouth, day); } } } printf("这一天是这一年的第%d天\n", num); return 0; }

#include<stdio.h> int main() { int x = 0, y = 0, z = 0; int temp = 0; printf(
"请输入三个整数（如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("从小到大的排列顺序为：%d < %d < %d\n", x, y, z); return 0; }

#include<stdio.h> int main() { printf("****\n"); printf("*\n"); printf("*\n");
printf("****\n"); return 0; }

ASCII码，十进制0~126可显示，大于126时显示汉字

#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; }

#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; }

#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; }

#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; }

#include<stdio.h> int main() { int shu_zi = 0, shu_zi_1 = 1, shu_zi_2 = 1,
xun_huan= 0; printf("请输入数字编号："); scanf("%d", &shu_zi); if(shu_zi <= 1) { printf(
"结果是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("结果是%d\n",
shu_zi_2); } return 0; }

#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("请输入数字编号："); scanf("%d", &shu_zi);
printf("结果是%d\n", f(shu_zi)); return 0; }

#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("请输入数字编号："); scanf("%d", &shu_zi); printf("结果是%d\n", f(
shu_zi)); return 0; }

#include<stdio.h> int shu[100] = {1, 1}; //全局变量 int f(int shu_zi) { //int
shu[100] = {1, 1}; //局部变量 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("请输入数字编号："); scanf("%d", &shu_zi); printf("结果是%d\n", f(
shu_zi)); return 0; }

#include<stdio.h> int main() { int a = 1, b = 1, i = 0; for(i = 1; i <= 10; i++
) //输出数列的前20项 { printf("%d %d ", a, b); a = a + b; b = b + a; } printf("\n");
return 0; }

#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) //因为偶数一定不是素数，步长为2更高效 { k = (int)
sqrt(i); for(j = 2; j <= k; j++)//只需在2到根号i之间找因数 { if(i % j == 0) { flag = 0;
//用flag标记所有数，如果找到因数，将flag赋值为0 } } if(flag != 0) { printf("%d ", i); count++; if(
count% 5 == 0) { printf("\n"); } } flag = 1; //下次循环开始前将flag重置 } printf("\n");
printf("101~200之间一共有%d个素数\n", count); return 0; }

/* *日期：2020年4月8日 *题目：求一个数字是否为素数 *输入：无 *输出： */ #include <stdio.h> #include
<math.h> int main() { int xunhuan = 0; int gen = 0; int shuzi = 0; printf(
"请输入一个数："); scanf("%d", &shuzi); gen = sqrt(shuzi); for(xunhuan = 2; xunhuan <
gen; xunhuan++) { if(!(shuzi % xunhuan)) break; } if (xunhuan <= gen) { printf(
"%d不是素数\n", shuzi); } else { printf("%d 是素数\n", shuzi); } return 0; }

本身。例如：153是一个“水仙花数”，因为153=1的三次方＋5的三次方＋3的三次方
#include<stdio.h> #include<math.h> int main() { int i = 0, ge = 0, shi = 0, bai
= 0; printf("请输出所有的水仙花：\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; }

/* *日期：2020年4月14日 *题目：将一个正整数分解质因数。例如：输入90,打印出90=2*3*3*5。
*分析：对n进行分解质因数，应先找到一个最小的质数k，然后按下述步骤完成： 如果这个质数恰等于n，则说明分解质因数的过程已经结束，打印出即可。

*输入：无 *输出： */ #include<stdio.h> int main() { int num = 0, i = 0; printf(
"输入一个正整数："); 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; }

60分以下的用C表示。
#include<stdio.h> int main() { int score = 0; char grade = 0; printf("请输入学习成绩："
); scanf("%d", &score); grade = (score >= 90) ? 'A' : ((score < 60) ? 'C' : 'B')
; printf("%d 属于%c\n", score, grade); return 0; }

#include<stdio.h> int main() { int m = 0, n = 0, a = 0,b = 0, temp = 0; printf(
"请输入两个正整数：(如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;) //辗转相除法 { m = n; n = temp;
temp= m % n; } printf("最小公约数是%d,最小公倍数是%d\n", n, a * b / n); return 0; }

#include<stdio.h> int main() { char c = 0; int letter = 0, space = 0, digit = 0
, other = 0; printf("请输入字符串："); 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(
"字符串中共有字母%d,空格%d,数字%d,其他字符%d\n", letter, space, digit, other); return 0; }

：求s=a+aa+aaa+aaaa+aa…a的值，其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加)，几个数相加有键盘控制。
#include<stdio.h> int main() { int a = 0, n = 0, count = 1; long int sn = 0, tn
= 0; printf("请输入数字和有几个数相加(如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; }

#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; //算出所有因子的和 } }
if(sum == i) { printf("%d ", i); } sum = 0; //重置sum } printf("\n"); return 0; }

#include<stdio.h> int main() { double sum = 100.0, h = sum / 2; //h为每次反弹的高度 int
i= 0; for(i = 2; i <= 10; i++) //sum,h初值为第一次落地数值，i应从2开始 { sum = sum + h * 2;
// 两次落地间经过了上升和落下两次反弹的高度 h = h / 2; } printf("第10次落地时，共经过%f米，第10次反弹的高度%f\n", sum,
h); return 0; }