《C语言部分编程题.doc》由会员分享,可在线阅读,更多相关《C语言部分编程题.doc(2页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、数字反序#includestdio.hvoid main()int x,a,b,c;printf(input xn);scanf(%d,&x);if(x99&xc&a+cb&b+ca)s=(a+b+c)/2;area=sqrt(s*(s-a)*(s-b)*(s-c);printf(area=%f,area);elseprintf(it is wrong);#includestdio.hvoid main() 年int i,d,year ,mouth,day; 月int sum=0;printf(input year mouth dayn); 日scanf(%d%d%d,&year ,&mout
2、h,&day);for(i=1;imouth;i+)switch(i)case 1:case 3:case 5:case 7:case 8:case 10:d=31;break;case 4:case 6:case 9:case 11:d=30;break;case 2:if(year%4=0&year%100!=0|year%400=0) d=29; else d=28;sum=sum+d;sum=sum+day;printf(sum=%d,sum); #includestdio.hint f(int x); 素void main()int x;printf(input xn); 数scan
3、f(%d,&x);if(f(x)printf(it is );else printf(it is not); int f(int x)int i,s=1;for(i=2;i=x/2;i+)if(x%i=0)s=0;break;return s;Sn=8+88+888+8888#include stdio.hvoid main()long i,a,n,sum=0,sn=0;printf(“输入a,n”);scanf(“%d%d”,&a,&n);for(i=1;i=n;i+)sum=sum*10+a;sn=sn+sum;printf(“sn=%dn”,sn); 水仙花数#include stdio
4、.hvoid main()int n,x,y,z;printf(“The result is:”);for(x=1;x=9;x+)for(y=0;y=9;y+)for(z=0;z=9;z+)if(x*x*x+y*y*y+z*z*z=100*x+10*y+z)printf(“%dt”,100*x+10*y+z);printf(“n”);硬币的换法#include stdio.hvoid main()int x,y,z;for(x=5;x=65;x+=5) for(y=5;y=35;y+=5) for(z=5;z=17;z+=5) if(x+y*2+z*5=100) printf(“1分=%d个2分=%d个5分=%d个n”,x,y,z); ASCII码#include stdio.hvoid main()char x;scanf(%c,&x);if(x=9)printf(%cn,x);elseprintf(ASCII=%dn,x);