电脑,系统测试题1.docx

上传人:l*** 文档编号:81191159 上传时间:2023-03-24 格式:DOCX 页数:9 大小:13.46KB
返回 下载 相关 举报
电脑,系统测试题1.docx_第1页
第1页 / 共9页
电脑,系统测试题1.docx_第2页
第2页 / 共9页
点击查看更多>>
资源描述

《电脑,系统测试题1.docx》由会员分享,可在线阅读,更多相关《电脑,系统测试题1.docx(9页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、电脑,系统测试题1系统测试题1 1.功能:从键盘输入一个大写字母赋给c1,要求改用小写字母输出。#include <stdio.h> void main() char c1,c2; /*SPACE*/ c1= ; /*SPACE*/ c2= ; printf(“%c,%c“,c1,c2); 2.题目:下列程序的功能是输入一个正整数,推断是否能被3或7整除,若不能被3或7整除, 就输出“YES“,否则就输出“NO“。请填空。#include <stdio.h> void main( ) int k; /*SPACE*/ scanf (“%d“,); /*SPACE*/ i

2、f () printf(“YESn“); else printf (“NOn“); 3.题目:某等差数列的第一项a=2,公差d=3。下面程序的功能是在前n(1n10)项和中,输出全部项的和能被4整除者。请填空。#include <stdio.h> void main() int a,d,sum,n,i; /*SPACE*/ a=2; d=3;i=1;sum=; scanf(“%d“,n); do sum+=a; i+; /*SPACE*/ ; /*SPACE*/ if() printf(“%dn“,sum); while(i<=n); 4.题目:求100以内个位数为6且能够被

3、3整除的全部数 #include<stdio.h> void main() int i,j; /*SPACE*/ for(i=0;i+) j=i*10+6; /*SPACE*/ if() continue; printf(“%dt“,j); 5.题目:函数fun的功能是:统计长整数n的各位上出现数字1、2、3的次数,并用 外部(全局)变量c1、c2、c3返回主函数。例如:当n123114350时,结果应当为:c13 c21 c32。#include <stdio.h> int c1, c2, c3; void fun(long n) c1=c2=c3=0; while(

4、n) /*SPACE*/ switch() case 1: /*SPACE*/ c1+; case 2: /*SPACE*/ c2+; case 3: c3+; n/=10; main() long n=123114350L; fun(n); printf(“nThe result: n“); printf(“n=%ld c1=%d c2=%d c3=%dn“,n,c1,c2,c3); 6.题目:打印出11000中满意个位上的数字、十位上的数字和百位上的数字都相等的全部三位数。本题输出“111,222,333,444,555,666,777,888,999, “ #include <st

5、dio.h> main() int i,g, s, b; /*SPACE*/ for (; i<=1000; i+) /*SPACE*/ g=; s=(i/10)%10; /*SPACE*/ b=()%10; if(g=s s=b) printf(“%d,“,i); 7.题目:从键盘键盘输入3个整数,然后找出最小的数并输出。 例如:输入“10,41,31“, 输出 “三个数是:10,41,31.最小数是:10.“。 #include <stdio.h> #include <conio.h> main() int a, b, c, min; printf(“请

6、输入三个整数:n“); /*SPACE*/ scanf(“%d,%d,%d“,); printf(“三个数是:%d,%d,%d.“, a, b, c); if (a > b) min=b; else min=a; /*SPACE*/ if () min=c; /*SPACE*/ printf(“最小数是:“, min); 8.给定程序中,程序的功能是:从键盘输入的字符中统计数字字符 的个数,用换行符结束循环。请填空。例如:输入:CADX2012JSJ0623 输出:8 #include<stdio.h> void main() int n=0,c; c=getchar();

7、/*SPACE*/ while() /*SPACE*/ if() n+; c=getchar(); printf(“%d“,n); 9.题目:请输入一个大于100的正整数a,将a的百位、十位和个位依次放在b的个位、十位和百位上。例如:输入“321“,输出“结果是:123“。#include <conio.h> #include <stdio.h> main () int a,b; printf (“请输入一个大于100的正整数:“); /*SPACE*/ (“%d“, a); /*SPACE*/ b=()*100 + (a/10)%10)*10 + (a/100)%10

8、; /*SPACE*/ printf (“结果是: n“, b); 10.题目:计算两个正数数n 和 m(m<1000)之间全部数的和。n和m从键盘输入。 例如,输入“1,100“,输出“1到100之间全部数的和是:5050。“ #include <stdio.h> #include <conio.h> main() int i,n,m; long sum=0; printf(“请输入两个正整数:n,mn“); /*SPACE*/ scanf(“%d,%d“, ); /*SPACE*/ for(i=n; i+) /*SPACE*/ sum = sum+; prin

9、tf(“%d到%d之间全部数的和是:%ldn“, n, m, sum); 11.题目:以下程序输入n和n个大于1的正整数,输出其中素数。 如输入:5 19 93 11 37 15 则输出:19 11 37 例示说明:先输入n为5,再输入5个正整数,输出5个整数中的素数 #include <stdio.h> void main() int n, a, i, j, ct; scanf( “%d“, n ); /*SPACE*/ for ( i=0; i+ ) /*SPACE*/ ; scanf( “%d“, a ); for( j=2; j<a; j+ ) /*SPACE*/ i

10、f () ct+; if ( ct=0 ) printf( “%d “, a ); printf( “n“ ); 12.给定程序中,程序的功能是:从键盘输入的字符中统计数字字符的个数,用换行符结束循环。请填空。 例如: 输入:12ab34cd 输出:4 #include<stdio.h> void main() int n=0,c; c=getchar(); /*SPACE*/ while() /*SPACE*/ if() n+; c=getchar(); printf(“ %d个数字n“,n); 13.题目:求出 -10 到 30 之内能被 7 或 11 整除,但不能同时被 7

11、或 11 整除的全部整数。 例如:输出“-7,7,11,14,21,22,28,“。 #include <conio.h> #include <stdio.h> main() int i; /*SPACE*/ for(;i<=30; i+) /*SPACE*/ if( (i%7=0 i%11=0) i%77!=0) /*SPACE*/ (“%d,“,i); 14.题目:打印出11000中满意个位数字的立方等于其本身的全部数。 本题输出“1,64,125,216,729,“。 #include <stdio.h> main() int i, g; /*S

12、PACE*/ for (; i<=1000; i+) g = i%10; /*SPACE*/ if () /*SPACE*/ printf(“, i); 15.题目:从键盘键盘输入3个整数,然后找出最小的数并输出。 例如:输入“10,41,31“, 输出 “三个数是:10,41,31.最小数是:10.“。 #include <stdio.h> #include <conio.h> main() int a, b, c, min; printf(“请输入三个整数:n“); /*SPACE*/ (“%d,%d,%d“,a, b, c); printf(“三个数是:%d

13、,%d,%d.“, a, b, c); /*SPACE*/ if () min=b; else min=a; if (min > c) min=c; /*SPACE*/ printf(“最小数是:%d.“, ); 16.题目:从键盘输入一组整数,运用条件表达式找出最大的整数。 当输入的整数为 0 时结束。 例如,输入 1 2 3 5 4 0 时,输出“max=5“。 #include <stdio.h> #include <conio.h> main() int num=-1; int max = 0; printf(“请输入一组整数: n“); /*SPACE*

14、/ while() /*SPACE*/ scanf(“%d“, ); max = num>max ? num : max; /*SPACE*/ (“max=%dn“, max); 17.题目:甲乙丙丁4人同时起先放鞭炮,甲每隔t1 s放一次,乙每隔t2 s放一次,丙每隔t3 s放一次,丁每隔t4 s放一次,每人各放n次。函数fun的功能是依据形参炸响,只算一次响声,第一次响声是在第0s。例如:若t17,t25,t36,t44,n10,则总共可听到28次鞭炮声。#include <stdio.h> /*SPACE*/ #define OK(i, t, n) (=0) (i/t&

15、lt;n) int fun(int t1, int t2, int t3, int t4, int n) int count, t , maxt=t1; if (maxt < t2) maxt = t2; if (maxt < t3) maxt = t3; if (maxt < t4) maxt = t4; count=1; /* 给count赋初值 */ /*SPACE*/ for(t=1; t< maxt*(n-1); ) if(OK(t, t1, n) | OK(t, t2, n)| OK(t, t3, n) | OK(t, t4, n) ) count+; /*

16、SPACE*/ return ; main() int t1=7, t2=5, t3=6, t4=4, n=10, r; r = fun(t1, t2, t3, t4, n); printf(“The sound : %dn“, r); 18.下面的程序是求1!+3!+5!+n!的和。#include <stdio.h> main() long int f,s; int i,j,n; /*SPACE*/ ; scanf(“%d“,n); /*SPACE*/ for(i=1;i<=n; ) f=1; /*SPACE*/ for(j=1; ;j+) /*SPACE*/ ; s=s+f; printf(“n=%d,s=%ldn“,n,s);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > 工作计划

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com