资源描述:
《谭浩强 C语言程序设计 课后习题答案 所有的程序都有.doc》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、第三章3.4main(){inta,b,c; longintu,n; floatx,y,z; charc1,c2; a=3;b=4;c=5; x=1.2;y=2.4;z=-3.6; u=51274;n=128765; c1='a';c2='b'; printf(""); printf("a=%2d b=%2d c=%2d",a,b,c); printf("x=%8.6f,y=%8.6f,z=%9.6f",x,y,z); printf("x+y=%5.2f y+z=%5.2f z+x=%5
2、.2f",x+y,y+z,z+x); printf("u=%6ld n=%9ld",u,n); printf("c1='%c'or%d(ASCII)",c1,c1); printf("c2='%c'or%d(ASCII)",c2,c2);}3.557 5 767.856400,-789.12396267.856400,-789.123962 67.86-789.12,67.856400,-789.123962,67.856400,-789.1239626.785640e+001,-
3、7.89e+002A,65,101,411234567,4553207,d68765535,177777,ffff,-1COMPUTER, COM3.6a=3b=7/x=8.5y=71.82/c1=Ac2=a/3.7 10 20Aa1.5-3.75+1.4,67.8/(空3)10(空3)20Aa1.5(空1)-3.75(空1)(随意输入一个数),67.8回车3.8main(){floatpi,h,r,l,s,sq,sv,sz; pi=3.1415926; printf("inputr,h")
4、; scanf("%f,%f",&r,&h); l=2*pi*r; s=r*r*pi; sq=4*pi*r*r; sv=4.0/3.0*pi*r*r*r; sz=pi*r*r*h; printf("l=%6.2f",l); printf("s=%6.2f",s); printf("sq=%6.2f",sq); printf("vq=%6.2f",sv); printf("vz=%6.2f",sz);}3.9main(){floatc,f; scanf("%f",&f); c=(5
5、.0/9.0)*(f-32); printf("c=%5.2f",c);}3.10#include"stdio.h"main(){charc1,c2; scanf("%c,%c",&c1,&c2); putchar(c1); putchar(c2); printf(""); printf("%c%c",c1,c2);}第四章4.3(1)0 (2)1 (3)1 (4)0 (5)14.4main(){inta,b,c; scanf("%d,%d,%d",&a,&b,&c); if(a
6、 if(bb)?a:b; max=(c>temp)?c:temp; printf("max=%d",max);} 4.5mai
7、n(){intx,y; scanf("%d",&x); if(x<1)y=x; elseif(x<10)y=2*x-1; elsey=3*x-11; printf("y=%d",y);}4.6main(){intscore,temp,logic; chargrade; logic=1; while(logic) {scanf("%d",&score); if(score>=0&&score<=100)logic=0; } if(score==100) temp=9; else temp=
8、(score-score%10)/10; switch(temp) {case9:grade='A';break; case8:grade='B';break; case7:grade='C';break; case6:grade='D';break; case5: case4: case3: case2: case1: case0:grade='E'; } printf"score=%d,grade=%c",score,gra