资源描述:
《c语言程序设计苏小红版答案解析》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、WORD格式可编辑2.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("%d",(float)(a*b)/2);printf("%d",(int)x%(int)y);}3.2#includemain(){intx,b0,b1,b2,s;printf(
2、"Inputx:");scanf("%d",&x);b2=x/100;b1=(x-b2*100)/10;b0=x%10;s=b0*100+b1*10+b2;printf("s=%d",s);}3.3#include#includemain(){floatrate=0.0225;floatn,capital,deposit;printf("Inputn,capital:");scanf("%f,%f",&n,&capital);deposit=capital*pow(1+rate,n);printf("deposit=%f",d
3、eposit);}3.4#include#includemain(){floata,b,c;专业知识整理分享WORD格式可编辑doublex,y;printf("Inputa,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",x,y);}4.1(1)#includemain(){charc1='a',c2='b',c3='c';printf("
4、a%cb%cc%c",c1,c2,c3);}4.1(2)#includemain(){inta=12,b=15;printf("a=%d%%,b=%d%%",a,b);}4.1(3)#includemain(){inta,b;scanf("%2d%*2s%2d",&a,&b);printf("%d,%d",a,b);}4.2#includemain(){longa,b;floatx,y;scanf("%d,%d",&a,&b);scanf("%f,%f",&x,&y);printf("a=%d,
5、b=%d",a,b);printf("x=%f,b=%f",x,y);}5.1#includemain(){floata;printf("Innputa:");scanf("%f",&a);if(a>=0){专业知识整理分享WORD格式可编辑a=a;printf("a=%f",a);}else{a=-a;printf("a=%f",a);}}5.2#includemain(){inta;printf("Inputa:");scanf("%d",&a);if(a%2==0){printf("a是偶数");}else{p
6、rintf("a是奇数");}}5.3#include#includemain(){floata,b,c,s,area;printf("Inputa,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",area);}else{printf("不是三角形");}}5.4#include#include专业
7、知识整理分享WORD格式可编辑main(){floata,b,c,x,y;printf("Inputa,b,c:");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);y=(-b-sqrt(b*b-4*a*c))/(2*a);printf("x=%f,y=%f",x,y);}elseif(b*b-4*a*c==0){x=-b/(2*a);y=-b/(2*a);printf("x=%f,y