资源描述:
《c语言程序设计第三版谭浩强课后习题答案完整版》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1.5#includevoidmain(){printf("*********************************");printf("Verygood!");printf("*********************************");}1.6#includevoidmain(){floatmax(floatx,floaty,floatz);floata,b,c;printf("请分别输入a,b,c:");scanf("%f,%f,%f",&a,&b,&c);printf
2、("max=%f",max(a,b,c));}floatmax(floatx,floaty,floatz){floatm,n;m=x>y?x:y;n=m>z?m:z;return(n);}3.6#includevoidmain(){charc1=’a’,c2=’b’,c3=’c’,c4=’101’,c5=’116’;printf(“a%cb%ctc%ctabc”,c1,c2,c3);printf(“tb%c%c”,c4,c5);}3.9.1#includevoidmain(){doublex
3、=2.5,y=4.7,z;inta=7;z=x+a%3*(int)(x+y)%2/4;printf("该表达式的值为:%f",z);}3.9.2#includevoidmain(){inta=2,b=3;floatx=3.5,y=2.5,z;z=(float)(a+b)/2+(int)x%(int)y;printf("该表达式的值为:%f",z);}4.5#includevoidmain(){inta=5,b=7;doublex=67.8564,y=-789.124;charc='A';longn=123456
4、7;unsignedu=65535;printf("%d%d",a,b);printf("%3d%3d",a,b);printf("%f,%f",x,y);printf("%-10f,%-10f",x,y);printf("%8.2f,%8.2f,%.4f,%.4f,%3f,%3f",x,y,x,y,x,y);printf("%e,%10.2e",x,y);printf("%c,%d,%o,%x",n,n,n);printf("%ld,%lo,%x",n,n,n);printf("%u,%o,%x,%d",u,
5、u,u,u);printf("%s,%5.3s","COMPUTER","COMPUTER");}4.6#includevoidmain(){inta,b;floatx,y;charc1,c2;scanf("a=%db=%d",&a,&b);scanf("%f%e",&x,&y);scanf("%c%c",&c1,&c2);}4.7#includevoidmain(){inta,b;floatx,y,z;charc1,c2;scanf("%5d%5d",&a,&b);scanf("%f%f%*f%f",&x
6、,&y,&z);scanf("%c%c",&c1,&c2);}4.8#include#definepi3.14voidmain(){floatr,h,l,s1,s2,v1,v2;printf("请输入r,h的值:");scanf("%f,%f",&r,&h);l=2*pi*r;s1=pi*r*r;s2=4*s1;v1=4/3*pi*r*r*r;v2=s1*h;printf("圆周长为:%.2f",l);printf("圆面积为:%.2f",s1);printf("圆球表面积为:%.2f",s2);printf("
7、圆球体积为:%.2f",v1);printf("圆柱体积为:%.2f",v2);}5.5#includevoidmain(){floatx,y;printf("请输入x的值:");scanf("%f",&x);if(x<1)y=x;elseif(x>=1&&x<10)y=2*x-1;elsey=3*x-11;printf("x与y的值分别为:%f,%f",x,y);printf("");}5.6#includevoidmain(){floatb;inta;printf("请输入该同学的成绩:
8、");scanf("%f",&b);while(b<0
9、
10、b>100){printf("输入有误,请重新输入:");scanf(