C语言程序设计课后答案-罗朝盛

上传人:s9****2 文档编号:544711421 上传时间:2023-05-22 格式:DOC 页数:39 大小:163.51KB
返回 下载 相关 举报
C语言程序设计课后答案-罗朝盛_第1页
第1页 / 共39页
C语言程序设计课后答案-罗朝盛_第2页
第2页 / 共39页
C语言程序设计课后答案-罗朝盛_第3页
第3页 / 共39页
C语言程序设计课后答案-罗朝盛_第4页
第4页 / 共39页
C语言程序设计课后答案-罗朝盛_第5页
第5页 / 共39页
点击查看更多>>
资源描述

《C语言程序设计课后答案-罗朝盛》由会员分享,可在线阅读,更多相关《C语言程序设计课后答案-罗朝盛(39页珍藏版)》请在金锄头文库上搜索。

1、第1章 习题参考答案1. (略)2 判断题123453 填空题(1) main(2) 函数的首部、函数体(3) 、(4) main、main(5) 语句、分号(;)4 选择题12345CCCAB5 选择题(1)#include main() int a, b, s; float t; printf(Enter A,B=?n);scanf(%d%d, &a, &b); s=a+b; t=a*b; printf(s=%d, t=%fn, s, t);(2)#include main() printf(=n);printf( Hello! n); printf( How do you do n);

2、printf(=n);(3)#include main() int r, h; float v;printf(Enter R, H=?n); scanf(%d%d, &r, &h); v=3.1415926*r*r*h; printf(v=%fn,v);第2章 习题参考答案一(略)二填空题(1)(2) 2.5(3) 16(4) 10(5) 16、16、11(6) 4、10、6(7) 18、3、3(8) sin(65*3.14/180)+2*(3.1415926 +exp(y))/(x-y)(9) 25、25(10) 27(11) 4(12) 0三、 选择题123456789101112DDCB

3、DADBCDAB四、编程题1#include main() int x, a, b, c; printf(Enter a intger number x=?n); scanf(%d,&x); a=x /100; b=x%100/10; c=x%10; printf(%d %d %dn, a, b, c);2.#include main() unsigned a, b,r1,r2,r3; scanf(%u%u, &a, &b); r1=a &b; r2=a|b; r3=ab; printf(r1=%u,r2=%u,r3=%un,r1,r2,r3); getch();3.#include main

4、() float a, b, h, s; scanf(%f%f?%f, &a, &b, &h); s=(a+b)*h/2; printf(s=%fn, s);第3章 习题参考答案一、判断题1234562 填空题3 语句4 表达式语句5 6 函数7 由“%”和格式字符8 &9 getchar()10 27 ,33 ,1b11 x(1)=23.14 x(2)=-78.32 12 5+ 63 程序阅读题1、p=3.14p=3.1416p= 3.14p= 3.1416p=3.14p=3.14162、a-ASCII: 97a-ASCII: 97a-ASCII: 974 编程题1、 #include ma

5、in() int a, b; float r1, r2; scanf(%d%d, &a, &b); r2=a+b; r1=a*b/r2; printf(r1=%0.2f,r2=%0.2fn, r1, r2);2、#include main() float c, f; printf(Input C=); scanf(%f, &c); f=9.0/5*c+32; printf(F=%fn, f);3、#include void main() float c1, c2, c3, ver, s; printf(Input a, b and c:); scanf(%f%f%f, &c1, &c2, &c

6、3); s=c1+c2+c3; ver=s/3; printf(total s=%f , ver=%fn, s,ver); 第4章 习题参考答案1 判断题1234562 选择题12345678BBBBDABB3 程序阅读题(1) 105(2) a=8(3) abc123DEF(4)4 程序填空题(1) chch=)count-count=0count0(2) div=ndiv(3) min=mark min=mark max=mark sum+=mark5 编程题(1) #include void main( ) int x,y; printf(Enter the X,Y=?n); scanf

7、(%d,%d,&x,&y); if(x0 & y0) printf(%d,%d)是第一像限n,x,y); else if(x0 & y0) printf(%d,%d)是第四像限n,x,y); else if(x0) printf(%d,%d)是第三像限n,x,y); else if(x0 & y0 & y=0) printf(%d,%d)在X轴正方向n,x,y); else if(x0) printf(%d,%d)在Y轴正方向n,x,y); else if(x=0 & y0) printf(%d,%d)在Y轴负方向n,x,y); else printf(%d,%d)为坐标原点n,x,y);(2

8、)#include #include main() float a, b, c, x, s; printf(Input a, b and c:); scanf(%f%f%f, &a, &b, &c); if(a+b=c | a+c=b | b+c=a) printf(Error!n); else x=(a+b+c)/2; s=sqrt(x*(x-a)*(x-b)*(x-c); printf(area=%fn, s); (3)程序代码如下:#include void main() float salary, tax; int ntax; printf(nPlease enter a salary

9、=); scanf(%f,&salary); ntax=salary/500; if (ntax=10) ntax=10; switch(ntax) case 0: case 1: tax=0;break; case 2: tax=(salary-1000)*0.05;break; case 3:case 4: tax=500*0.05+(salary-1500)*0.1;break; case 5:case 6: tax=500*0.05+1000*0.1+(salary-2500)*0.15;break; case 7:case 8:case 9: tax=500*0.05+1000*0.

10、1+1000*0.15+(salary-3500)*0.20;break; case 10: tax=500*0.05+1000*0.1+1000*0.15+1500*0.20+(salary-5000)*0.30; printf(nThe tax=%10.2fn,tax); (4)方法一#include #include main() int i=1; float t=-1, s=0; do t= -t/i; s=s+t; i=i+1; while(fabs(t)1e-6); printf(s=%fn, s); 方法二#include void main() int i=1,sign=1; float t=1.0, s=0.0; while(1.0/t1e-6) t= t*i; s=s+sign/t; i=i+1; sign=-sign; ; printf(s=%fn, s);(5)方法一:#include main() int i, a, b, c; for(i=100; i=999; i+) a=i /100; b=i/10%10; c=i%10; if(i=a*a*a+b*b*b+c*c*c) printf(%dn, i); 方法二:#include void main() int i, a, b, c; for(a=1; a=9; a+) for(

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 习题/试题

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号