0)y=1;elseif(x=0)y=0;elsey=-1;p"> 0)y=1;elseif(x=0)y=0;elsey=-1;p" />
c语言程序设计(何钦铭颜晖著)高等教育出版社第三章课后答案

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

ID:37187297

大小:40.01 KB

页数:5页

时间:2019-05-21

c语言程序设计(何钦铭颜晖著)高等教育出版社第三章课后答案_第1页
c语言程序设计(何钦铭颜晖著)高等教育出版社第三章课后答案_第2页
c语言程序设计(何钦铭颜晖著)高等教育出版社第三章课后答案_第3页
c语言程序设计(何钦铭颜晖著)高等教育出版社第三章课后答案_第4页
c语言程序设计(何钦铭颜晖著)高等教育出版社第三章课后答案_第5页
资源描述:

《c语言程序设计(何钦铭颜晖著)高等教育出版社第三章课后答案》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、练习3-2#includevoidmain(){floatx;inty;printf("PleaseInputx:");scanf("%f",&x);if(x>0)y=1;elseif(x=0)y=0;elsey=-1;printf("sign(%f)=%d",x,y);}练习3-3#includevoidmain(){inti,letter,digit,space,other;charch;letter=digit=space=other=0;printf("PleaseInput1

2、5charactors:");for(i=1;i<=15;i++){ch=getchar();if(ch==''

3、

4、ch=='')space++;elseif(ch>='0'&&ch<='9')digit++;elseif((ch>='A'&&ch<='Z')

5、

6、(ch>='a'&&ch<='z'))letter++;elseother++;}printf("letters=%d,digits=%d,spaces=%d,others=%d",letter,digit,space,other);}练习3-6#inclu

7、devoidmain(){charch;printf("PleaseInputgrade(A~E):");ch=getchar();switch(ch){case'A':printf("Thescoreisbetween90--100.");break;case'B':printf("Thescoreisbetween80--89.");break;case'C':printf("Thescoreisbetween70--79.");break;case'D':printf("Thescorei

8、sbetween60--69.");break;case'E':printf("Thescoreisbetween0--59.");break;default:printf("Inputerror!");break;}}练习3-7#includevoidmain(){inti,ch;floatprice;for(i=1;i<=5;i++){printf("[1]apples");printf("[2]pears");printf("[3]oranges");printf("[4]gr

9、apes");printf("[0]Exit");printf("Pleasechoice(0~4):");scanf("%d",&ch);if(ch==0)break;switch(ch){case1:price=3.0;break;case2:price=2.5;break;case3:price=4.1;break;case4:price=10.2;break;default:price=0.0;break;}printf("Thepriceis%.1f.",price);}}练习3-8#include

10、tdio.h>voidmain(){intyear;printf("Pleaseinputayear:");scanf("%d",&year);if((year%4==0&&year%100!=0)

11、

12、(year%400==0))printf("Yes.");elseprintf("No.");}练习3-9#includevoidmain(){inti,n,num=0;floatscore,total=0;printf("Pleaseinputnumbersofstudent:");scanf("%

13、d",&n);for(i=1;i<=n;i++){printf("Pleaseinputscore#%d(0~100):",i);scanf("%f",&score);if(score>=60)num++;total=total+score;}printf("Theaveragescoreis%.2f.",total/n);printf("Thenumbersofpassingis%d.",num);}练习3-10#includevoidmain(){doublex,y;printf("Please

14、inputx:");scanf("%lf",&x);if(x>15)y=2.5*x-10.5;elseif(x<0)y=0;elsey=4*x/3;printf("y=f(%lf)=%lf",x,y);}习题3-1#include#includevoi

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。