资源描述:
《华南农业大学c语言上机实验答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、格式:一题号一答案,相对应1001#include"stdio.h"intmain(){inta,b;scanf("%d%d",&a,&b);printf("%d",a+b);}1007#include"stdio.h"intmain(){inta,b;scanf("%d%d",&a,&b);printf("%d",a+b);}1014#include"stdio.h"voidmain(){floatarea,r;scanf("%f",&r);area=3.14159*r*r;printf("%0.2f",
2、area);}1015#includevoidmain(){floatf,c;scanf("%f",&f);c=5.0/9*(f-32);printf("%.2f",c);}1016#includemain(){chara,b,c,d,e;scanf("%c%c%c%c%c",&a,&b,&c,&d,&e);if(a<='Z'&&a>='A')a=a+32;if(b<='Z'&&b>='A')b=b+32;if(c<='Z'&&c>='A')c=c+32;if(d<='Z
3、'&&d>='A')d=d+32;if(e<='Z'&&e>='A')e=e+32;printf("%c%c%c%c%c",a,b,c,d,e);}1017#include"stdio.h"voidmain(){intn,place;scanf("%ld",&n);if(n>99999999)place=9;elseif(n>9999999)place=8;elseif(n>999999)place=7;elseif(n>99999)place=6;elseif(n>9999)place=5;elseif(
4、n>999)place=4;elseif(n>99)place=3;elseif(n>9)place=2;elseplace=1;printf("%ld",place);}1018#includemain(){inta,b,c,t;scanf("%d,%d,%d",&a,&b,&c);if(a>b){t=a;a=b;b=t;}if(a>c){t=a;a=c;c=t;}if(b>c){t=b;b=c;c=t;}printf("%d,%d,%d",a,b,c);}1019#include"
5、stdio.h"main(){inta,b,c,d,e;scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);if(a%27==0)printf("YES");elseprintf("NO");if(b%27==0)printf("YES");elseprintf("NO");if(c%27==0)printf("YES");elseprintf("NO");if(d%27==0)printf("YES");elseprintf("NO");if(e%27==
6、0)printf("YES");elseprintf("NO");}1020#include"stdio.h"main(){intn;scanf("%d",&n);if(n<0)printf("negative");elseprintf("positive");if(n%2==0)printf("even");elseprintf("odd");}1023#includeintmain(){floata,b,c;charop;scanf("%f%c%f",&a,&o
7、p,&b);switch(op){case'+':c=a+b;break;case'-':c=a-b;break;case'*':c=a*b;break;case'/':c=a/b;break;default:printf("error");break;}printf("result=%.2f",c);}1024#includevoidmain(){longi,n=1,a;scanf("%ld",&a);for(i=1;i<=a;i++)n=n*i;printf("%ld",n);}1
8、025#includevoidmain(){longn,sum=0,i,t=1;scanf("%ld",&n);for(i=1;i<=n;i++){sum=sum+t;t=t+2;}printf("%ld",sum);}1026#includevoidmain(){charc;ints=0,a;while((c=getchar())!=''){if(c>='0'&&c<