资源描述:
《c语言程序设计习题相关解答》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、谭浩强C语言程序设计习题答案C语言程序设计习题参考答案第一章1.6main(){inta,b,c,max;printf("inputthreenumbers:");scanf("%d,%d,%d",&a,&b,&c);max=a;if(max
2、ff91)16(6)(2483)10=(4663)8=(963)16(7)(-28654)10=(110022)8=(9012)16(8)(21003)10=(51013)8=(520b)162.6aabb(8)cc(8)abc(7)AN2.7main(){charc1='C',c2='h',c3='i',c4='n',c5='a';c1+=4,c2+=4,c3+=4,c4+=4,c5+=4;printf("%c%c%c%c%c",c1,c2,c3,c4,c5);}2.8main(){intc1,c2;c1=97;c2=98;printf("%c%c",c1,c2);}2.9(
3、1)=2.5(2)=3.52.109,11,9,1012.12(1)24(2)10(3)60(4)0(5)0(6)0第三章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=%2db=%2dc=%2d",a,b,c);printf("x=%8.6f,y=%8.6f,z=%9.6f",x,y,z);printf("x+y=%5.2fy+z=%5.2fz+x=%
4、5.2f",x+y,y+z,z+x);printf("u=%6ldn=%9ld",u,n);printf("c1='%c'or%d(ASCII)",c1,c1);printf("c2='%c'or%d(ASCII)",c2,c2);}3.5575767.856400,-789.12396267.856400,-789.12396267.86-789.12,67.856400,-789.123962,67.856400,-789.1239626.785640e+001,-7.89e+002A,65,101,411234567,4553207,d68765535,177
5、777,ffff,-1COMPUTER,COM3.6a=3b=7/x=8.5y=71.82/c1=Ac2=a/3.71020Aa1.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");2scanf("%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.
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.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",
7、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