下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、电脑,系统测试题3 系统测试题3 1.从键盘键盘输入3个整数,然后找出最大的数并输出。 例如:输入“12,45,43“, 输出 “三个数是:12,45,43.最大数是:45.“。 #include stdio.h> #include conio.h> main() int a, b, c, max; printf(“请输入三个整数:n“); /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】(“%d,%d,%d“,&a, &b, &c); printf(“三个数是:%d,%d,%d.“, a, b, c); /xxxxxxxxxxxx
2、*spacexxxxxxxxxxxx*/ if (【?】) max=a; else max=b; if (maxc) max=c; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ printf(“最大数是:%d.“, 【?】); 2.从键盘输入一组整数,使用条件表达式找出最大的整数。当输入的整数为 0 时结束。 例如,输入 1 2 3 5 4 0 时,输出“max=5“。 #include stdio.h> #include conio.h> main() int num=-1; int max = 0; printf(“请输入一组整数: n“); /xxxxx
3、xxxxxxx*spacexxxxxxxxxxxx*/ 【?】(num!=0) scanf(“%d“,&num); /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/max = 【?】 ? num : max; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】(“max=%dn“, max); 3.输入三个整数x,y,z,请把这三个数由小到大输出。 #include stdio.h> main() int x,y,z,t; scanf(“%d%d%d“,&x,&y,&z); /xxxxxxxxxxxx*spacex
4、xxxxxxxxxxx*/ if (x>y)【?】 /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ if(x>z)【?】 /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ if(y>z)【?】 printf(“small to big: %d %d %dn“,x,y,z); 4.从键盘输入n,求不大于n的各正偶数之和。 例如,输入“10“,输出“10以内偶数和:30。“ #include stdio.h> int fun(int x) /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ int s=【?】,i; /x
5、xxxxxxxxxxx*spacexxxxxxxxxxxx*/ for (i=2; 【?】; i+=2) /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/【?】 += i; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】 s; main() int n; printf(“请输入一个正整数n:“); /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ scanf(“%d“, 【?】); printf(“%d以内偶数和:%d。“, n, fun(n); 5.从键盘上输入两个复数的实部与虚部,求出并输出它们的和、差、积、商。 #inclu
6、destdio.h> void main() float a,b,c,d,e,f; printf(“输入第一个复数的实部与虚部:“); scanf(“%f, %f“,&a,&b); printf(“输入第二个复数的实部与虚部:“); scanf(“%f, %f“,&c,&d); /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】; f=b+d; printf(“相加后复数:实部:%f,虚部:%fn“,e,f); e=a*c-b*d; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】; printf(“相乘后
7、复数:实部:%f,虚部:%fn“,e,f); e=(a*c+b*d)/(c*c+d*d); /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】; printf(“相除后复数:实部:%f,虚部:%fn“,e,f); 6.输出fibonacci数列的前15项,要求每行输出5项。 fibonacci数列:1,1,2,3,5,8,13. #include stdio.h> main() /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ int 【?】14,i; fib0=1;fib1=1; for (i=2;i15;i+) /xxxxxxxxxxxx*s
8、pacexxxxxxxxxxxx*/ fibi=【?】; for(i=0;i15;i+) printf(“%dt“,fibi); /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ if ( 【?】 ) printf(“n“); 7.编程求任意给定的n个数中的奇数的连乘积,偶数的平方和以及0的个数,n通过scanf()函数输入。 #include stdio.h> main() int r=1,s=0,t=0,n,a,i; printf(“n=“);scanf(“%d“,&n); for(i=1;i=n;i+) printf(“a=“); /xxxxxxxxxxx
9、x*spacexxxxxxxxxxxx*/ scanf(“%d“,【?】); /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ if(【?】!=0) /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】=a; else if(a!=0) /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ s+=【?】; else t+; printf(“r=%d,s=%d,t=%dn“,r,s,t); 8.两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。已抽签决定比赛名单。有人向队员打听比赛的名单。a说他不和x比,c说他不和x
10、,z比,请编程序找出三队赛手的名单。 #include stdio.h> main() char i,j,k;/*i是a的对手,j是b的对手,k是c的对手*/ for(i=x;i=z;i+) for(j=x;j=z;j+) /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ if(【?】) /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ for(k=x;【?】;k+) /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ if(【?】) /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ if(i!=x&&
11、k!=【?】) printf(“order is a-%ctb-%ctc-%cn“,i,j,k); 9.1982年我国第三次人口普查,结果全国人口为10.3亿,假如人口增长率为5%。编写一个程序求在公元多少年总人口翻了一番。 #includestdio.h> void main() double p1=10.3,p2,r=0.05; int n=1; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ p2=p1*【?】; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ while(p2=【?】) n+; /xxxxxxxxxxxx*spacexxxx
12、xxxxxxxx*/ p2=p2*【?】; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ n=【?】; printf(“%d年人口总数翻了一番,即为%g亿人n“,n,p2); 10.下列程序从键盘输入所需数据,求出z的值并输出,要求输出结果保留2位小数。 #include stdio.h> /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】 main() int x; double y,z; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ scanf(“【?】“,&x,&y); z=2*x*sqrt(y);
13、 /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ printf(“z=【?】“,z); 11.计算平均成绩并统计90分以上人数。 #include stdio.h> main() int n,m; float grade,average; average=0.0; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ n=m=【?】; while(1) /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】(“%f“,&grade); if(grade0) break; n+; average+=grade; /xxxxxxx
14、xxxxx*spacexxxxxxxxxxxx*/ if(grade90)【?】; m+; if(n) printf(“%.2f%dn“,average/n,m); 12.识别输入的字符串,每个单词输出一行 #include stdio.h> #include string.h> void main() int c; int inspace; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】; while(c = getchar() != n) if(c = | c = t | c = n) /xxxxxxxxxxxx*spacexxxxxxxxxxxx*
15、/ if(【?】) inspace = 1; putchar(n); else inspace = 0; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】; 13.输出1到100之间每位数的乘积大于每位数的和的数。 例如:数字26,数位上数字的乘积12大于数字之和8。 #include stdio.h> main() int n,k=1,s=0,m; for(n=1;n=100;n+) k=1; s=0; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】 ; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ while
16、( 【?】 ) k*=m%10; s+=m%10; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ 【?】; if(k>s) printf(“%d “,n); 14.打印出如下图案(菱形) * xxx* xxxxx* xxxxxxx* xxxxx* xxx* * #include stdio.h> main() int i,j,k; /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ for(i=0;【?】;i+) for(j=0;j=4-i;j+) printf(“ “); /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ f
17、or(k=1;k=【?】;k+) printf(“*“); printf(“n“); /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ for(【?】;j3;j+) for(k=0;kj+3;k+) printf(“ “); for(k=0;k5-2*j;k+) printf(“*“); printf(“n“); 15.计算一元二次方程的根。 #include stdio.h> /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ #include 【?】 main() double x1,x2,imagpart; float a,b,c,disc,realpart; scanf(“%f%f%f“,&a,&b,&c); printf(“the equation“); /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ if(【?】=1e-6) printf(“is not quadraticn“); else disc=b*b-4*a*c; if(fabs(disc)=1e-6) printf(“has two equal roots:%-8.4fn“,-b/(2*a); /xxxxxxxxxxxx*spacexxxxxxxxxxxx*/ else i
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/Z 10062.32-2025锥齿轮承载能力计算方法第32部分:锥齿轮和准双曲面齿轮的ISO评价体系胶合承载能力算例
- 2026北京印钞有限公司招聘26人考试参考试题及答案解析
- 2026传奇腾芳幼儿园公开招聘5人考试参考题库及答案解析
- 2026年1月广西百色市田阳区城镇公益性岗位工作人员招聘1人考试备考试题及答案解析
- 2026重庆医科大学编外聘用人员招聘(第2轮)考试备考试题及答案解析
- 2026江西吉安市井冈山垦殖场农产品开发有限责任公司面向社会招聘3人考试参考试题及答案解析
- 2026广西南宁马山县人民法院招聘1人考试备考题库及答案解析
- 胺碘酮的儿科应用
- 2025浙江杭州余杭水务有限公司招聘36人考试备考题库及答案解析
- 2026江西晶昊盐化有限公司专业技术技能人才(第二次)招聘6人考试备考试题及答案解析
- 边坡支护安全监理实施细则范文(3篇)
- 6.1.3化学反应速率与反应限度(第3课时 化学反应的限度) 课件 高中化学新苏教版必修第二册(2022-2023学年)
- 北京市西城区第8中学2026届生物高二上期末学业质量监测模拟试题含解析
- 2026年辽宁轻工职业学院单招综合素质考试参考题库带答案解析
- 2026届北京市清华大学附中数学高二上期末调研模拟试题含解析
- 2026年马年德育实践作业(图文版)
- 四川省成都市武侯区西川中学2024-2025学年八上期末数学试卷(解析版)
- 2026年《必背60题》抖音本地生活BD经理高频面试题包含详细解答
- 2024人教版七年级数学上册全册教案
- 小儿外科学:腹膜后肿瘤
- 表格1《齐鲁护理杂志》审稿专家遴选登记表
评论
0/150
提交评论