资源描述:
《《C语言程序设计》课后习题答案高等教育出版社》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、.672.2#includemain(){floatx=2.5,y=2.5,z=2.5;printf(,,x=%f,,,x);printf("y=%f",y);printf(,,z=%f",z);}3.1(1)#includemain(){inta=12,b=3;floatx=18.5,y=4.6;printf(“%f”,(float)(a*b)/2);printf(,,%d,,,(int)x%(int)y);}3.1(2)#includemain(){intx=32,y=8
2、1,p,q;p=x++;q=-y;printf("%d%d",p,q);printf("%d%dH,x,y);}3.2#includemain(){intx,b0,bl,b2,s;printf("lnputx:");scanf(”%d”,&x);b2=x/100;bl=(x-b2*100)/10;//或(x%100)/10;或x/10%10;b0=x%10;s=bO*100+bl*10+b2;printf(Hs=%d",s);}3.3#include#includemain(){flo
3、atrate=0.0225;floatn^capital,deposit;printf("lnputn,capital:");scanf("%f,%f",&n,&capital);deposit=capital*pow(l+rate,n);printf("deposit=%f",deposit);}3.4#include#includemain(){floata,b,c;doublex,y;printf("lnputa,b,c:");scanf("%f%f%f",&a,&b,&c);x=(-b+sqrt(b*b
4、-4*a*c))/(2*a);y=(-b-sqrt(b*b-4*a*c))/(2*a);printf(,,x=%f,y=%f,,,x/y);}c语言习题44.1(1)#includemain().501{charcl=,a,,c2='bc3='c,;printf(Ma%cb%cc%c,cllc2,c3);}4.1⑵#includemainQinta=12,b=15;printf(,,a=%d%%,b=%d%%,,la/b);4・1⑶#includemainQinta,b;scan
5、fC,%2d%*2s%2d,&a,&b);printf("%d,%d"ab);}4.2#includemain(){longa,b;floatx,y;scanf("%d,%d",&a,&b);scanf(”%f,%f",&x,&y);printf(,,a=%d,b=%d,,/a/b);printf("x=%f/b=%f",x,y);}5.1#includemain(){floata;printf(nInputa:");scanf("%f&a);if(a>=0){a=a;printf(,,a
6、=%f,,,a);}else{a=-a;printf(,,a=%f,,,a);}}5.2#includemain()inta;printf("lnputa:");scanfC%dH,&a);if(a%2==0)}else{printfC'a是奇数”);}}5.3#include#includemain(){floata,b,c,s,area;printff'lnputa,b,c:");scanf("%f%f%f',&a,&b,&c);if(a+b>c&&a+c>b&&b+c>a){s=(a
7、+b+c)/2;area=(float)sqrt(s*(s-a)*(s-b)*(s-c));printf(',area=%f",area);}else{printf不是三角形“);}}5.4#include#includemain(){floata,b,c,x,y;printf(,'lnputa,b,c:H);scanf(“%f,%f,%f:&a,&b,&c);if(a==0){printf(”该方程不是一元二次方程”);}if(b*b-4*a*c>0)x=(-b+sqrt(b*b-4*a*c))/(2*a
8、);y=(-b-sqrt(b*b-4*a*c))/(2*a);printf(Mx=%f,y=%fH,x,y);}els