资源描述:
《C语言作业实验报告》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、2,(1)switch语句实现#includevoidmain(){intscore;printf("Pleaseinputascore:");scanf("%d",&score);if(score<0
2、
3、score>100)printf("Pleaseinputtherightscore!");else{switch(score/10){case10:case9:printf("A");break;case8:printf("B");break;case7:print
4、f("C");break;case6:printf("D");break;default:printf("E");}}}(2)if语句实现#includevoidmain(){intscore;printf("Pleaseinputascore:");scanf("%d",&score);if(score<0
5、
6、score>100)printf("Pleaseinputarightscore!");else{if(score/10>=9)printf("A");
7、if(score/10==8)printf("B");if(score/10==7)printf("C");if(score/10==6)printf("D");if(score/10<=5)printf("E");}}3,#includevoidmain(){intnumber,a,b,c,d,e;printf("Pleaseinputanumber:");scanf("%d",&number);if(number<0
8、
9、number>99999)printf("
10、Thenumberisoutofcompass!");else{a=number%10;if(a==number){printf("Thenumberis1.");printf("%d",a);printf("%d",a);}else{b=number/10%10;if(b==number/10){printf("Yhenumberis2.");printf("%d%d",b,a);printf("%d%d",a,b);}else{c=number/100%10;if(c==nu
11、mber/100){printf("Thenumberis3.");printf("%d%d%d",c,b,a);printf("%d%d%d",a,b,c);}else{d=number/1000%10;if(d==number/1000){printf("Thenumberis4.");printf("%d%d%d%d",d,c,b,a);printf("%d%d%d%d",a,b,c,d);}else{e=number/10000;printf("Thenumberis5.
12、");printf("%d%d%d%d%d",e,d,c,b,a);printf("%d%d%d%d%d",a,b,c,d,e);}}}}}}4,#includevoidmain(){inta,b,c,x;printf("Pleaseinputthreenumbers:");scanf("%d",&a);scanf("%d",&b);scanf("%d",&c);if(a>b){x=a;a=b;b=x;}if(c13、lse{if(c#includevoidmain(){floata,b,c,m,s;printf("Pleaseinputlengths");scanf("%f",&a);scanf("%f",&b);scanf("%f",&c);if(a+b>c&&a+c>b&&b+c>a){m=(a+b+c)*(a+b-c)*(a+c-b)*(
14、b+c-a);s=sqrt(m)/4;printf("%f",s);if(a==b&&b==c)printf("DengBianSanJiaoXing");else{if(a==b
15、
16、b==c
17、
18、c==a)printf("DengYaoSanJiaoXing");else{if(a*a+b*b==c*c
19、
20、a*a+c*c==b*b
21、
22、b*b+c*c==a*a)printf("ZhiJiaoSanJiaoXing");elseprintf