




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- O2O电商创业机会的探索
- 护理环境与安全
- 2024-2025学年下学期高二英语人教版同步经典题精练之动词词义辨析
- 安徽省安庆市潜山市第二中学2025年高三下学期一模考试化学试题含解析
- 员工需要什么样的培训
- 传染病宣传课件
- 中国古代音乐教育
- 二零二四年份六月《阿房宫赋》古代水利工程模拟教学实验设计
- 冰川科普知识
- 燃料电池GRC销售合同催化剂衰减补偿2025
- 露天矿石土方剥离工程施工组织设计
- X-Y数控工作台机电系统设计说明书
- 公司管理创新工作管理办法
- 轮胎式装载机检测报告
- 部编版四年级语文下册《亲爱的汉修先生》整本书导读课件(共38张PPT)
- 世界地理之欧洲西部
- 主动脉球囊反搏术(IABP)监测及护理
- 民办教师人员花名册
- 国家开放大学《管理英语4》章节测试参考答案
- 石文软件-GXPLORER使用说明书_图文
- 一卡通数据库字典
评论
0/150
提交评论