下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、xt4-4-1#include <stdio.h>int main()int a,b,c;printf(" 请输入三个整数:");scanf("%d,%d,%d",&a,&b,&c);if (a<b)if (b<c)printf("max=%dn",c);elseprintf("max=%dn",b);else if (a<c)printf("max=%dn",c);elseprintf("max=%dn",a);retu
2、rn 0; xt4-4-2#include <stdio.h>int main() int a,b,c,temp,max;printf(" 请输入三个整数:");scanf("%d,%d,%d",&a,&b,&c);temp=(a>b)?a:b;/*将 a 和 b 中的大者存入temp 中 */max=(temp>c)?temp:c;/* 将 a 和 b 中的大者与c 比较 ,取最大者*/printf(" 三个整数的最大数是%dn",max);return 0; xt4-5#includ
3、e <stdio.h>#include <math.h>#define M 1000 int main() int i,k;printf(" 请输入一个小于%d 的整数 i:",M);scanf("%d",&i);if (i>M)printf(" 输入的数不符合要求,请重新输入一个小于%d 的整数 i:",M);scanf("%d",&i);k=sqrt(i);printf("%d 的平方根的整数部分是:%dn",i,k);return 0; xt4
4、-5-2#include <stdio.h>#include <math.h>#define M 1000int main()int i,k;printf(" 请输入一个小于%d 的整数 i:",M);scanf("%d",&i);while (i>M)printf(" 输入的数不符合要求,请重新输入一个小于%d 的整数 i:",M);scanf("%d",&i);k=sqrt(i);printf("%d 的平方根的整数部分是:%dn",i,k);r
5、eturn 0; xt4-6#include <stdio.h>int main() int x,y;printf(" 输入 x:");scanf("%d",&x);if(x<1)/* x<1 */ y=x;printf("x=%3d,y=x=%dn" ,x,y);else if(x<10) y=2*x-1;/* 1=<x<10 */printf("x=%d, y=2*x-1=%dn",x,y);else/* x>=10*/ y=3*x-11;printf(&
6、quot;x=%d, y=3*x-11=%dn",x,y);return 0; xt4-7-1#include <stdio.h>int main()int x,y;printf("enter x:");scanf("%d",&x);y=-1;if(x!=0)if(x>0)y=1;elsey=0;printf("x=%d,y=%dn",x,y);return 0; xt4-7-2#include <stdio.h>int main()int x,y;printf("please
7、 enter x:");scanf("%d",&x);y=0;if(x>=0)if(x>0) y=1;else y=-1;printf("x=%d,y=%dn",x,y);return 0; xt4-8#include <stdio.h>int main() float score;char grade;printf(" 请输入学生成绩:");scanf("%f",&score);while (score>100|score<0)printf("
8、;n 输入有误,请重输 ");scanf("%f",&score);switch(int)(score/10)case 10:case 9: grade='A'break;case 8: grade='B'break;case 7: grade='C'break;case 6: grade='D'break;case 5:case 4:case 3:case 2:case 1:case 0: grade='E'printf(" 成绩是 %5.1f, 相应的等级是%cn
9、 ",score,grade);return 0; xt4-9#include <stdio.h>#include <math.h>int main()int num,indiv,ten,hundred,thousand,ten_thousand,place;/分别代表个位,十位,百位, 千位 , 万位和位数printf(" 请输入一个整数(0-99999):");scanf("%d",&num);if (num>9999)place=5;else if (num>999)place=4;else i
10、f (num>99)place=3;else if (num>9)place=2;else place=1;printf(" 位数 :%dn",place);printf(" 每位数字为:");ten_thousand=num/10000;thousand=(int)(num-ten_thousand*10000)/1000;hundred=(int)(num-ten_thousand*10000-thousand*1000)/100;ten=(int)(num-ten_thousand*10000-thousand*1000-hundred
11、*100)/10;indiv=(int)(num-ten_thousand*10000-thousand*1000-hundred*100-ten*10); switch(place)case 5:printf("%d,%d,%d,%d,%d",ten_thousand,thousand,hundred,ten,indiv);printf("n 反序数字为:");printf("%d%d%d%d%dn",indiv,ten,hundred,thousand,ten_thousand); break;case 4:printf(&quo
12、t;%d,%d,%d,%d",thousand,hundred,ten,indiv);printf("n 反序数字为:");printf("%d%d%d%dn",indiv,ten,hundred,thousand);break;case 3:printf("%d,%d,%d",hundred,ten,indiv);printf("n 反序数字为:");printf("%d%d%dn",indiv,ten,hundred);break;case 2:printf("%d,%d
13、",ten,indiv);printf("n 反序数字为:");printf("%d%dn",indiv,ten);break;case 1:printf("%d",indiv);printf("n 反序数字为:");printf("%dn",indiv);break;return 0;xt4-10-1#include <stdio.h>int main()int i;double bonus,bon1,bon2,bon4,bon6,bon10;bon1=100000*0.
14、1;bon2=bon1+100000*0.075;bon4=bon2+100000*0.05;bon6=bon4+100000*0.03;bon10=bon6+400000*0.015;printf(" 请输入利润i:");scanf("%d",&i);if (i<=100000)bonus=i*0.1;else if (i<=200000)bonus=bon1+(i-100000)*0.075;else if (i<=400000)bonus=bon2+(i-200000)*0.05;else if (i<=600000
15、)bonus=bon4+(i-400000)*0.03;else if (i<=1000000)bonus=bon6+(i-600000)*0.015;elsebonus=bon10+(i-1000000)*0.01;printf(" 奖金是 : %10.2fn",bonus);return 0; xt4-10-2#include <stdio.h>int main()int i;double bonus,bon1,bon2,bon4,bon6,bon10;int branch;bon1=100000*0.1;bon2=bon1+100000*0.075;
16、bon4=bon2+200000*0.05;bon6=bon4+200000*0.03;bon10=bon6+400000*0.015;printf(" 请输入利润i:");scanf("%d",&i);branch=i/100000;if (branch>10) branch=10;switch(branch) case 0:bonus=i*0.1;break;case 1:bonus=bon1+(i-100000)*0.075;break;case 2:case 3: bonus=bon2+(i-200000)*0.05;break;c
17、ase 4:case 5: bonus=bon4+(i-400000)*0.03;break;case 6:case 7:case 8:case 9: bonus=bon6+(i-600000)*0.015;break;case 10: bonus=bon10+(i-1000000)*0.01;printf(" 奖金是 %10.2fn",bonus);return 0; xt4-11#include <stdio.h>int main()int t,a,b,c,d;printf(" 请输入四个数:");scanf("%d,%d,%d
18、,%d",&a,&b,&c,&d);printf("a=%d,b=%d,c=%d,d=%dn",a,b,c,d);if (a>b) t=a;a=b;b=t;if (a>c) t=a;a=c;c=t;if (a>d) t=a;a=d;d=t;if (b>c) t=b;b=c;c=t;if (b>d) t=b;b=d;d=t;if (c>d) t=c;c=d;d=t;printf(" 排序结果如下: n");printf("%d %d %d %d n",a,b,c,d);return 0; xt4-12#include <stdio.h>int main()int h=10;float x1=2,y1=2,x2=-2,y2=2,x3=-2,y3=-2,x4=2,y4=-2,x,y,d1,d2,d3,d4;printf(" 请输入一个点(x,y):");scanf("
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024-2030年中国变形棱镜行业竞争态势与盈利前景预测报告
- 2024-2030年中国变压器附件市场产销规模预测与前景供需平衡分析报告
- 2024-2030年中国发酵监测器行业运营态势与前景动态预测报告
- 2024-2030年中国双壁碳纳米管行业深度评估及供需平衡预测报告
- 2024-2030年中国厨具行业市场深度调研及投资价值与投资前景研究报告
- 2024-2030年中国印钞机行业市场发展趋势与前景展望战略分析报告
- 2024-2030年中国卫星机器对机器(M2M)通信行业市场发展趋势与前景展望战略分析报告
- 2024-2030年中国南瓜籽油补品行业市场发展趋势与前景展望战略分析报告
- 2024-2030年中国半导体致冷晶棒产业投资商机与未来发展方向趋势报告
- 2024-2030年中国医药制剂行业供需趋势及投资风险研究报告
- 安全生产教育培训台账
- 体检进度计划书
- 新能源概论.技术介绍
- 人工智能在石油地球物理勘探中的应用研究综述
- 高考必背3500词单词表-纯粹英文单词-无词性-无中文
- 就业能力展示个人人工智能
- 护栏工程施工监理细则文本
- 2024年永州职业技术学院高职单招(英语/数学/语文)笔试历年参考题库含答案解析
- 2023年驻马店市事业单位统考真题及答案
- 护士长在护理信息化建设中的推动作用
- 中华民国史:政治、经济与社会变迁
评论
0/150
提交评论