1、C 语言编程题覆盖到的算法:1、个人所得税计算;2、求一组数的正、负数(或奇、偶数)的个数和平均值;3、二维数组主、次对角线之和;4、求素数(用函数实现) ;5、级数有限项求和问题;6、两个一维数组相加(用函数实现) ;7、 求最大、最小值;8、判断闰年(用函数实现) ;9、求水仙花数;10、百钱百鸡;11、求最大公约数、最小公倍数。12、求回文数;13、排序;14、二维数组的转置;15、递归函数求阶乘;16、求斐波那契数列;17、求和:a+aa+aaa+aaaa+;18、求符合条件的整数(如:是某个二位数的平方,个位、十位、百位数各不相同等) ;(包括素数,回文,完数,等等)19、字符串加密
2、;20、统计字符串中字母和数字的个数;/*1.个人所得税计算,以实验指导 P24T5 为标准*/#includevoid main()int i,n;double a,b,c;n=i/400;printf(“please input income:n“);scanf(“%d“,a=(i-800)*0.05,b=20+(i-1200)*0.08,c=84+(i-2000)*0.2;switch(n)case 0:case 1:printf(“不需缴税n“);break;case 2:printf(“需交纳%lf 元n“,a);break;case 3:case 4:printf(“需交纳%lf
3、元n“,b);break;default:printf(“需交纳%lf 元n“,c);break;/*2. 求一组数的奇数个数,偶数个数和平均值#include#define N 10void main()int aN;int i,m=0,n=0,sum=0;double average;printf(“please input 10 numbers:n“);for(i=0;i#define N 10void main()int aN;int i,m=0,n=0,sum=0;double average;printf(“please input 10 numbers:n“);for(i=0;i
4、0)m+;elsen+;sum+=ai;average=(double)sum/N;printf(“we have %d positive numbers and %d nagetive numbersn“,m,n);printf(“the average =%lf“,average);/*3.求二维数组的主次对角线之和*/#include#define M 5 #define N 5void main()int aMN;int i,j,sum1=0,sum2=0;printf(“please input the matrix:n“);for(i=0;i#includeint isPrime(
5、int n)int i;for(i=1;i#includevoid main()int n=1;double p=0,t,pi;t=1/(pow(-1),(n+1)*2*(n-1);while(fabs(t)=1e-6)pi+=t;n+;pi=4*p;printf(“%lf“,pi);/6.两个一维数组相加/*#include#define N 5void main()int aN,bN,cN;int i;printf(“please input the first array aN:n“);for(i=0;i#define N 5int f(int a,int b)int sum;sum=a
6、+b;return sum;void main()int aN,bN,cN;int i;printf(“please input the first array aN:n“);for(i=0;ivoid main()int i,max,min;int a10;printf(“please input ten numbersn“);for(i=0;imax)max=ai;if(ai#includevoid main()int i,max,min;int a10;for (i=0;imax)max=ai;if(aiint f(int n)if(n%4=0elsereturn 0;void main
7、()int n;printf(“please input year:n“);scanf(“%d“,if(f(n)printf(“%d 是闰年n“,n);elseprintf(“%d 不是闰年 n“,n);/*可能会有要输出某一范围内所有闰年,思想一样,用循环调用函数即可*/*9.判断水仙花数(运用循环)#includevoid main()int n,a,b,c,m;printf(“please input a number:n“);scanf(“%d“,a=n/100;b=n/10%10;c=n%10;m=a*a*a+b*b*b+c*c*c;if(m=n)printf(“%d is the
8、number we wantn“,n);elseprintf(“%d is not the numbern“,n);*/*9.输出所有水仙花数(调用函数(书 P108 为循环做法) )*/#includeint f(int n)int a,b,c,m;a=n/100;b=n/10%10;c=n%10;m=a*a*a+b*b*b+c*c*c;if(m=n)return 1;elsereturn 0;void main()int i,t;for(i=100;ivoid main()int i,j,k;for(i=0;iint f(int m,int n)int i=1,t;if(mvoid mai
9、n()int i,j,k=0,a;printf(“10-2000 之间的回文数有:n“);for(i=10;i0)j=j*10+a%10;a/=10;if(i=j)printf(“%dt“,i);k+;if(k%5=0)printf(“n“);printf(“n“);*/12.2 输出 10-2000 之间的回文数(函数调用) /*#includeint f(int n)int i=0;while(n0)i=i*10+n%10;n/=10;return i;void main()int n,k;printf(“10-2000 之间的回文数有:n“);for(n=10;nvoid main()i
10、nt i,a,j=0;printf(“please input a number:n“);scanf(“%d“,a=i;while(a0)j=j*10+a%10;a/=10;if(j=i)printf(“%d 是回文数 n“,i);elseprintf(“%d 不是回文数 n“,i);*/12.4 判断回文数(函数调用)/#includeint f(int n)int i=0;while(n0)i=i*10+n%10;n/=10;return i;void main()int n;printf(“please inpit a number:n“);scanf(“%d“,if(n=f(n)pri
11、ntf(“%d 是回文数 n“,n);elseprintf(“%d 不是回文数 n“,n);/13.排序/选择法/*#include#define N 10void f(int a,int n)int i,j,k,t;for(i=0;i#define N 5void f(int a,int n)int i,j;int t;for(i=0;iaj+1)t=aj;aj=aj+1;aj+1=t;*/插入法/#include#define N 5void f(int a,int n)int i,j;int t;for(i=0;i0-j;aj=t;void main()int aN=8,2,34,5,1
12、2;int i=0;int size=sizeof(a)/sizeof(int);for(i=0;i#define N 3#define M 3void main()int aMN,bMN;int i,j;printf(“please input aMNn“);for(i=0;iint f(int n)if(n=1|n=0)return 1;elsereturn f(n-1)*n;void main()int n,m;printf(“please input a number:n“);scanf(“%d“,m=f(n);printf(“%d!=%dn“,n,m);/*16.运用递归函数求斐波拉
13、契数列(前 30 项)*/#includeint f(int n)if (n=1|n=2)return 1;elsereturn f(n-1)+f(n-2);void main()int i,k=0;for (i=1;i#include#define N 5void main()int n,i,j,k,a,sum1=0;printf(“please input a number:n“);scanf(“%d“,for(i=1;i#define N 5int k(int a,int sum)sum=sum*10+a;return sum;void main()int a,i=0,j,sum=0;printf(“please input a number:n“);scanf(“%d“,sum=k(a,k(a,sum);printf(“sum=%dn“,sum);/18.求符合条件的整数(如是某个二位数的平方,个位、十位、百位数各不相同等)/#includevoid main()int a,b,c,n,m;for(m=10;m#include#define N 80void main()char strN;char *p;printf(“please input the code:n“);gets(str);p=str;while(*p!=0)*p+=2;p+;