voidmain(){floata,b,c,t;scanf(“%f%f%f”,&a,&b,&c);if(a2、
3、year%400==0的值为
4、真时表示是闰年。#includevoidmain(){intyear;scanf(“%d”,&year);if(year%4==0&&year%100!=0
5、
6、year%400==0)printf(“yes”);elseprintf(“no”);}3.输入一行字符,分别统计其中英文字母、数字和其它字符的个数。#include"stdio.h"voidmain(){ints1=0,s2=0,s3=0;charc;scanf("%c",&c);while(c!=''){if(c>='a'&&c<='z'
7、
8、c>='A'&&c<='Z')s1=
9、s1+1;elseif(c>='0'&&c<='9')s2=s2+1;elses3++;scanf("%c",&c);}printf("s1=%d,s2=%d,s3=%d",s1,s2,s3);}1.输入n,求1!+2!+...+n!。#includevoidmain(){inti,n;longs=0,t=1;scanf("%d",&n);for(i=1;i<=n;i++){t=t*i;s=s+t;}printf("%d!=%ld",n,s);}2.输出2~100内所有的素数。#includevoidmain(){i
10、nti,j,f;for(i=2;i<=100;i++){f=1;for(j=2;j<=i-1;j++)if(i%j==0)f=0;if(f==1)printf("%5d",i);}}3.打印所有“水仙花数”,所谓“水仙花数”是指一个三位数,其各位数字的立方和等于该数本身。#include"stdio.h"voidmain(){inti,a,b,c;for(i=100;i<=999;i++){a=i/100;b=i/10%10;c=i%10;if(a*a*a+b*b*b+c*c*c==i)printf("%5d",i);}}4.一个数如果恰好等于它的因子之和,这
11、个数称为“完数”,输出1000之内的所有完数。#includevoidmain(){inti,j,s;for(i=2;i<1000;i++){s=0;for(j=1;jvoidmain(){inta,b,c,d;for(a=1;a<=9;a++)for(b=1;b
12、<=19;b++)for(c=1;c<=37;c++){d=40-a-b-c;if(d>0&&a*10+b*5+c*2+d==100)printf("%5d%5d%5d%5d",a,b,c,d);}}2.输出九九乘法表#includevoidmain(){inti,j;for(i=1;i<=9;i++){for(j=1;j<=i;j++)printf("%2d*%2d=%2d",i,j,i*j);printf("");}}3.求菲波拉挈数列前20项之和。#include"stdio.h"voidmain(){longa[20]={1,
13、1},i,s=2;for(i=2;i<=19;i++){a[i]=a[i-1]+a[i-2];s=s+a[i];}for(i=0;i<=19;i++)printf("%5ld",a[i]);printf("s=%ld",s);}1.编写函数求两个正整数的最大公约数和最小公倍数。#includeintgcd(inta,intb);intlcm(inta,intb);voidmain(){inta,b,m,n;printf("pleaseinput:");scanf("%d%d",&a,&b);m=gcd(a,b);n=lcm(a,b);
14、printf("gcd(%d,%d)=