电脑,系统测试题1

来源:卫生资格 发布时间:2020-07-27 点击:

系统测试题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***********/ if (【?】) printf(“YES\n“); else printf (“NO\n“); } 3.题目:某等差数列的第一项a=2,公差d=3。下面程序的功能是在前n(1≤n≤10)项和中,输出所有项的和能被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(“%d\n“,sum); }while(i<=n); } 4.题目:求100以内个位数为6且能够被3整除的所有数 #include<stdio.h> void main() { int i,j; /***********SPACE***********/ for(i=0;【?】;i++) { j=i*10+6; /***********SPACE***********/ if(【?】) continue; printf(“%d\t“,j); } } 5.题目:函数fun的功能是:统计长整数n的各位上出现数字1、2、3的次数,并用 外部(全局)变量c1、c2、c3返回主函数。

例如:当n=123114350时,结果应该为:c1=3 c2=1 c3=2。

#include <stdio.h> int c1, c2, c3; void fun(long n) { c1=c2=c3=0; while(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=%d\n“,n,c1,c2,c3); } 6.题目:打印出1~1000中满足个位上的数字、十位上的数字和百位上的数字都相等的所有三位数。本题输出“111,222,333,444,555,666,777,888,999, “ #include <stdio.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(“请输入三个整数:\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(); /***********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; /***********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,m\n“); /***********SPACE***********/ scanf(“%d,%d“,【?】 ); /***********SPACE***********/ for(i=n;【?】; i++) { /***********SPACE***********/ sum = sum+【?】; } printf(“%d到%d之间所有数的和是:%ld\n“, 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***********/ if (【?】) 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 整除的所有整数。

例如:输出“-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.题目:打印出1~1000中满足个位数字的立方等于其本身的所有数。

本题输出“1,64,125,216,729,“。

#include <stdio.h> main() { int i, g; /***********SPACE***********/ 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,%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***********/ while(【?】) { /***********SPACE***********/ scanf(“%d“, 【?】); max = num>max ? num : max; } /***********SPACE***********/ 【?】(“max=%d\n“, max); } 17.题目:甲乙丙丁4人同时开始放鞭炮,甲每隔t1 s放一次,乙每隔t2 s放一次,丙每隔t3 s放一次,丁每隔t4 s放一次,每人各放n次。函数fun的功能是根据形参炸响,只算一次响声,第一次响声是在第0s。

例如:若t1=7,t2=5,t3=6,t4=4,n=10,则总共可听到28次鞭炮声。

#include <stdio.h> /***********SPACE***********/ #define OK(i, t, n) ((【?】==0) && (i/t<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++; } /***********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 : %d\n“, 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=%ld\n“,n,s); }

推荐访问:2017警察执法资格考试题库 2017计算机三级网络技术题库 2017苏教版语文五年级下册期末试卷 2017鄂州干部理论考试题库 2017贵州省无纸化学法用法考试答案 2017贵州省毕节市地区中考化学模拟试卷 2017邮政投递技能考试中级 2017辽宁拉票贿选案专题组织生活会发言 2017违规吃喝问题专项整治回头看自查报 2017追赶超越主题作风建设实施方案
上一篇:领导全县防汛工作例会上发言稿word例文
下一篇:2019跨年系列活动游戏策划

Copyright @ 2013 - 2018 优秀啊教育网 All Rights Reserved

优秀啊教育网 版权所有