C语言程序设计 (何钦铭 颜晖 著) 高等教育出版社第三章 课后答案.doc

上传人:PIYPING 文档编号:10615980 上传时间:2021-05-26 格式:DOC 页数:5 大小:40KB
返回 下载 相关 举报
C语言程序设计 (何钦铭 颜晖 著) 高等教育出版社第三章 课后答案.doc_第1页
第1页 / 共5页
C语言程序设计 (何钦铭 颜晖 著) 高等教育出版社第三章 课后答案.doc_第2页
第2页 / 共5页
C语言程序设计 (何钦铭 颜晖 著) 高等教育出版社第三章 课后答案.doc_第3页
第3页 / 共5页
C语言程序设计 (何钦铭 颜晖 著) 高等教育出版社第三章 课后答案.doc_第4页
第4页 / 共5页
C语言程序设计 (何钦铭 颜晖 著) 高等教育出版社第三章 课后答案.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《C语言程序设计 (何钦铭 颜晖 著) 高等教育出版社第三章 课后答案.doc》由会员分享,可在线阅读,更多相关《C语言程序设计 (何钦铭 颜晖 著) 高等教育出版社第三章 课后答案.doc(5页珍藏版)》请在三一文库上搜索。

1、练习32#include void main()float x;int y;printf(Please Input x: );scanf(%f,&x);if(x0)y=1;else if(x=0)y=0;else y=-1;printf(sign(%f)=%dn,x,y);练习33#include void main()int i,letter,digit,space,other;char ch;letter=digit=space=other=0;printf(Please Input 15 charactors: );for(i=1;i=0 & ch=A & ch=a & ch=z)let

2、ter+;else other+;printf(letters=%d,digits=%d,spaces=%d,others=%dn,letter,digit,space,other);练习36#include void main()char ch;printf(Please Input grade (AE): );ch=getchar();switch(ch)case A:printf(The score is between 90-100.n);break;case B:printf(The score is between 80- 89.n);break;case C:printf(The

3、 score is between 70- 79.n);break;case D:printf(The score is between 60- 69.n);break;case E:printf(The score is between 0- 59.n);break; default: printf(Input error!n);break;练习37#include void main()int i,ch;float price;for(i=1;i=5;i+) printf(1 applesn); printf(2 pearsn); printf(3 orangesn); printf(4

4、grapesn); printf(0 Exitn); printf(Please choice(04): );scanf(%d,&ch);if(ch=0)break; switch(ch)case 1:price=3.0;break;case 2:price=2.5;break;case 3:price=4.1;break;case 4:price=10.2;break;default: price=0.0;break;printf(The price is %.1f.n,price);练习38#include void main()int year;printf(Please input a

5、 year: );scanf(%d,&year);if(year%4=0 & year%100!=0) | (year%400=0)printf(Yes.n);else printf(No.n);练习39#include void main()int i,n,num=0;float score,total=0;printf(Please input numbers of student: );scanf(%d,&n);for(i=1;i=60)num+;total=total+score;printf(The average score is %.2f.n,total/n); printf(T

6、he numbers of passing is %d.n,num);练习310#include void main()double x,y;printf(Please input x: );scanf(%lf,&x);if(x15)y=2.5*x-10.5;elseif(x0)y=0;else y=4*x/3;printf(y=f(%lf)=%lfn,x,y);习题31#include #include void main()double a,b,c,s,area,perimeter;printf(Please input a,b,c. : );scanf(%lf%lf%lf,&a,&b,&

7、c);if(a+bc & b+ca & a+cb & a0 & b0 & c0)s=(a+b+c)/2;area=sqrt(s*(s-a)*(s-b)*(s-c);perimeter=2*s;printf(perimeter=%lf,area=%lfn,perimeter,area);else printf(These sides do not correspond to a valid triangle.n);习题32#include #include void main()double salary,tax,rate;printf(Please salary.: );scanf(%lf,&

8、salary);if(salary=850)rate=0;else if(salary=1350)rate=5;else if(salary=2850)rate=10;else if(salary=5850)rate=15;else rate=20;tax=rate*(salary-850)/100;printf(These tax is %.2lf.n,tax);习题34#include void main()int i,n,numa,numb,numc,numd,nume;float score,total=0;numa=numb=numc=numd=nume=0;printf(Pleas

9、e input numbers of student: );scanf(%d,&n);for(i=1;i=n;i+) printf(Please input score #%d(0100): ,i);scanf(%f,&score);if(score60)nume+;else if(score70)numd+;else if(score80)numc+;else if(score90)numb+;else if(score=100)numa+;total=total+score;printf(The average score is %.2f.n,total/n); printf(The nu

10、mbers of grade A(90100) is %d.n,numa); printf(The numbers of grade B(8089) is %d.n,numb); printf(The numbers of grade C(7079) is %d.n,numc); printf(The numbers of grade D(6069) is %d.n,numd); printf(The numbers of grade E(059) is %d.n,nume);习题35#include void main()int year;for(year=2000;year=2099;year+)if(year%4=0 & year%100!=0) | (year%400=0)printf(Year=%d.n,year);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1