c语⾔程序设计第四版⾼等教育出版社,《C语⾔程序设计》课后习题答案-⾼等教育出版社.
《C语⾔程序设计》课后习题答案-⾼等教育出版社.docx
2.2 #includemain(){float x=2.5,y=2.5,z=2.5;printf("x=%f\n",x);printf("y=%f\n",y);printf("z=%f\n",z);}
3.1(1) #includemain(){int a=12,b=3;float x=18.5,y=
4.6;printf("%f\n",(float)(a*b)/2);printf("%d\n",(int)x%(int)y);}3.1(2)#includemain(){int
x=32,y=81,p,q;p=x++;q=--y;printf("%d %d\n",p,q);printf("%d %d\n",x,y);}3.2 #includemain(){int
x,b0,b1,b2,s;printf("Inputx:");scanf("%d",&x);b2=x/100;b1=(x-b2*100)/10;//或(x%100)/10;或
x/10%10;b0=x%10;s=b0*100+b1*10+b2;printf("s=%d\n",s);}3.3 #include#includemain(){float rate=0.0225;float
n,capital,deposit;printf("Input
n,capital:");scanf("%f,%f",&n,&capital);deposit=capital*pow(1+rate,n);printf("deposit=%f\n",deposit);}3.4
c语言程序设计教材答案#include#includemain(){float a, b, c;double x, y;printf("Input a, b, c:");scanf("%f %f %f", &a, &b, &c);x=(-b+sqrt(b*b-
4*a*c))/(2*a);y=(-b-sqrt(b*b-4*a*c))/(2*a);printf("x=%f,y=%f\n",x,y);}习题44.1(1) #includemain(){char
c1='a',c2='b',c3='c';printf("a%cb%cc%c\n",c1,c2,c3);}4.1(2) #includemain(){int
a=12,b=15;printf("a=%d%%,b=%d%%\n",a,b);}4.1(3) #includemain(){int
a,b;scanf("%2d%*2s%2d",&a,&b);printf("%d,%d\n",a,b);}4.2 #includemain(){long a,b;float
x,y;scanf("%d,%d\n",&a,&b);scanf("%f,%f\n",&x,&y);printf("a=%d,b=%d\n",a,b);printf("x=%f,b=%f\n",x,y);}5.1 #includemain() {float a;printf("Input a:");scanf("%f",&a);if(a>=0){a=a;printf("a=%f\n",a);}else{a=-a;printf("a=%f\n",a);}}5.2 #includemain(){int a;printf("Input a:");scanf("%d", &a);if(a%2==0){printf("a 是偶数");}else{printf("a 是奇数");}}5.3 #include#includemain(){float
a,b,c,s,area;printf("Input a, b, c:");scanf("%f %f %f", &a, &b, &c);if(a+b>c&&a+c>b&&b+c>a){s=(a+b+c)/2;area=(float)sqrt(s* (s-a)*(s-b)*(s-c));printf("area=%f\n",area);}else{printf("不是三⾓形");}}5.4 #include#includemain(){float
a,b,c,x,y;printf("Inputa,b,c:");scanf("%f,%f,%f",&a,&b,&c);if(a==0){printf("该⽅程不是⼀元⼆次⽅程\n");}if(b*b-4*a*c>0){x=(-
b+sqrt(b*b-4*a*c)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。