欢迎来到天天文库
浏览记录
ID:14228156
大小:119.00 KB
页数:27页
时间:2018-07-27
《c语言程序设计教程_李含光_郑关胜_清华大学出版社习题答案习题答案[完美打印版]》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第1章习题参考答案1.单项选择题(1)A(2)C(3)D(4)C(5)B2.填空题(1)函数(2)主函数(main)(3)printf(),scanf()第2章习题参考答案1.单项选择题1-5CBCCC6-10CDCDC11-13DBB2.填空题(1)1(2)26(3)6,4,2(4)10,6(5)3.000000(6)双精度(double)(7)9(8)字母,数字,下划线(9)13.700000(10)11(11)((m/10)%10)*100+(m/100)*10+m%10(12)0(13)10,9,11
2、(15)(x<0&&y<0)
3、
4、(x<0&&z<0)
5、
6、(y<0
7、
8、z<0)(16)double(17)x==0(18)sqrt(fabs(a-b))/(3*(a+b))(19)sqrt((x*x+y*y)/(a+b))第3章习题参考答案1.单项选择题1-5CCCDD6-10BCDBC11-15BCBBB16A2.填空题(1)用;表示结束(2){}(3)y=x<0?1:x==0?0:-1(4)y%4==0&&y%100!=0
9、
10、y%400==0(5)上面未配对(6)default标号(7)while,dowh
11、ile,for(8)dowhile(9)本次(10)本层3.阅读程序,指出结果(1)yes(2)*&(3)ABother(4)2870(5)2,0(6)8(7)36(8)1(9)3,1,-1,3,1,-1(10)a=12,y=12(11)i=6,k=4(12)1,-24.程序填空(1)x:y,u:z(2)m=n,m!=0,m=m/10(3)t12、ront,cx(6)doubles=0,1.0/k,%lf(7)s>=0,sintmain(){doublex,y;scanf("%lf",&x);if(x<1)y=x;elseif(x>=1.0&&x<10)y=2*x-11;elsey=3*x-11;printf("%lf",y);return0;}(2).#includeintmain(){doublex,y,z,min;scanf("%lf%lf%lf",&x,&13、y,&z);if(x>y)min=y;elsemin=x;if(min>z)min=z;printf("min=%lf",min);return0;}(3).#includeintmain(){inty,m,d,flag,s=0,w,i;scanf("%d%d%d",&y,&m,&d);flag=(y%4==0&&y%100!=014、15、y%400==0);w=((y-1)*365+(y-1)/4-(y-1)/100+(y-1)/400)%7;for(i=1;i<=m;i++){switch16、(i){case1:s=d;break;case2:s=31+d;break;case3:s=59+d;break;case4:s=90+d;break;case5:s=120+d;break;case6:s=151+d;break;case7:s=181+d;break;case8:s=212+d;break;case9:s=243+d;break;case10:s=273+d;break;case11:s=304+d;break;case12:s=334+d;break;}}if(flag==1&&m>217、)s=s+1;s=(w+s)%7;if(s==0)printf("星期日");elseprintf("星期%d",s);return0;27}(4).#includeintmain(){floatp,r;scanf("%f",&p);if(p<=10)r=p*0.1;elseif(p>10&&p<=20)r=10*0.1+(p-10)*0.075;elseif(p>20&&p<=40)r=10*0.1+10*0.075+(p-20)*0.05;elseif(p>40&&p<=60)r18、=10*0.1+10*0.075+20*0.05+(p-40)*0.03;elseif(p>60&&p<=100)r=10*0.1+10*0.075+20*0.05+20*0.03+(p-60)*0.015;elseif(p>100)r=10*0.1+10*0.075+20*0.05+20*0.03+40*0.015+(p-100)*0.01;printf("%f",r);return0;}(5
12、ront,cx(6)doubles=0,1.0/k,%lf(7)s>=0,sintmain(){doublex,y;scanf("%lf",&x);if(x<1)y=x;elseif(x>=1.0&&x<10)y=2*x-11;elsey=3*x-11;printf("%lf",y);return0;}(2).#includeintmain(){doublex,y,z,min;scanf("%lf%lf%lf",&x,&
13、y,&z);if(x>y)min=y;elsemin=x;if(min>z)min=z;printf("min=%lf",min);return0;}(3).#includeintmain(){inty,m,d,flag,s=0,w,i;scanf("%d%d%d",&y,&m,&d);flag=(y%4==0&&y%100!=0
14、
15、y%400==0);w=((y-1)*365+(y-1)/4-(y-1)/100+(y-1)/400)%7;for(i=1;i<=m;i++){switch
16、(i){case1:s=d;break;case2:s=31+d;break;case3:s=59+d;break;case4:s=90+d;break;case5:s=120+d;break;case6:s=151+d;break;case7:s=181+d;break;case8:s=212+d;break;case9:s=243+d;break;case10:s=273+d;break;case11:s=304+d;break;case12:s=334+d;break;}}if(flag==1&&m>2
17、)s=s+1;s=(w+s)%7;if(s==0)printf("星期日");elseprintf("星期%d",s);return0;27}(4).#includeintmain(){floatp,r;scanf("%f",&p);if(p<=10)r=p*0.1;elseif(p>10&&p<=20)r=10*0.1+(p-10)*0.075;elseif(p>20&&p<=40)r=10*0.1+10*0.075+(p-20)*0.05;elseif(p>40&&p<=60)r
18、=10*0.1+10*0.075+20*0.05+(p-40)*0.03;elseif(p>60&&p<=100)r=10*0.1+10*0.075+20*0.05+20*0.03+(p-60)*0.015;elseif(p>100)r=10*0.1+10*0.075+20*0.05+20*0.03+40*0.015+(p-100)*0.01;printf("%f",r);return0;}(5
此文档下载收益归作者所有