




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、练习32#include <stdio.h>void main()float x;int y;printf("Please Input x: ");scanf("%f",&x);if(x>0)y=1;else if(x=0)y=0;else y=-1;printf("sign(%f)=%dn",x,y);练习33#include <stdio.h>void main()int i,letter,digit,space,other;char ch;letter=digit=space=other=0
2、;printf("Please Input 15 charactors: ");for(i=1;i<=15;i+)ch=getchar();if(ch=' ' | ch='n')space+;else if(ch>='0' && ch<='9')digit+;else if(ch>='A' && ch<='Z') | (ch>='a' && ch<='z')l
3、etter+;else other+;printf("letters=%d,digits=%d,spaces=%d,others=%dn",letter,digit,space,other);练习36#include <stdio.h>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
4、'B':printf("The score is between 80- 89.n");break;case 'C':printf("The 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: prin
5、tf("Input error!n");break;练习37#include <stdio.h>void main()int i,ch;float price;for(i=1;i<=5;i+) printf("1 applesn"); printf("2 pearsn"); printf("3 orangesn"); printf("4 grapesn"); printf("0 Exitn"); printf("Please choice(04):
6、 ");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 <stdio.h>void main()int year;printf("Please inpu
7、t a year: ");scanf("%d",&year);if(year%4=0 && year%100!=0) | (year%400=0)printf("Yes.n");else printf("No.n");练习39#include <stdio.h>void main()int i,n,num=0;float score,total=0;printf("Please input numbers of student: ");scanf("%d&qu
8、ot;,&n);for(i=1;i<=n;i+) printf("Please input score #%d(0100): ",i);scanf("%f",&score);if(score>=60)num+;total=total+score;printf("The average score is %.2f.n",total/n); printf("The numbers of passing is %d.n",num);练习310#include <stdio.h>vo
9、id main()double x,y;printf("Please input x: ");scanf("%lf",&x);if(x>15)y=2.5*x-10.5;elseif(x<0)y=0;else y=4*x/3;printf("y=f(%lf)=%lfn",x,y);习题31#include <stdio.h>#include <math.h>void main()double a,b,c,s,area,perimeter;printf("Please input a,
10、b,c. : ");scanf("%lf%lf%lf",&a,&b,&c);if(a+b>c && b+c>a && a+c>b && a>0 && b>0 && c>0)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(&q
11、uot;These sides do not correspond to a valid triangle.n");习题32#include <stdio.h>#include <math.h>void main()double salary,tax,rate;printf("Please salary.: ");scanf("%lf",&salary);if(salary<=850)rate=0;else if(salary<=1350)rate=5;else if(salary<=2850)
12、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 <stdio.h>void main()int i,n,numa,numb,numc,numd,nume;float score,total=0;numa=numb=numc=numd=nume=0;printf("Please input numbers of student: ");sca
13、nf("%d",&n);for(i=1;i<=n;i+) printf("Please input score #%d(0100): ",i);scanf("%f",&score);if(score<60)nume+;else if(score<70)numd+;else if(score<80)numc+;else if(score<90)numb+;else if(score<=100)numa+;total=total+score;printf("The average score is %.2f.n",total/n); printf("The numbers 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(&
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 离职补偿合同范本
- 环卫项目合同范本
- 7 多元文化 多样魅力 第3课时 教学设计-2023-2024学年道德与法治六年级下册统编版
- 白杨教学设计
- 2023-2024学年泰山版信息技术(2018)第六册《第一单元 装扮美好生活 4 漂亮花瓶巧设计》教学设计
- Module 4 Unit 2 Children's Day(教学设计)-2023-2024学年牛津上海版(试用本)英语三年级下册
- Module 12 help unit 3 language in use教学设计 -2024-2025学年外研版八年级英语上册
- 新一年家长会教师的演讲稿
- 21凉州词教学设计-2024-2025学年四年级上册语文统编版
- 秋季学期散学典礼校长讲话稿
- PEP人教版小学英语单词卡片四年级下卡片
- 一通三防培训课件PPT课件(PPT 53页)
- 江苏省邳州市2021-2022学年人教版四年级上册期末数学试卷(含答案)
- 大数据分析及应用实践全书课件汇总整本书电子教案(最新)
- 教练技术一阶段讲义(共59页)
- 第3章-系统模型与模型化
- 精品课程建设验收自评报告
- 福建省义务教育课程设置及比例(修订)
- 未成年人需办银行卡证明(模板)
- 员工考勤流程图
- 出口加工区外汇管理培训(ppt49)
评论
0/150
提交评论