C语言考试改错填空编程题题库·.doc

上传人:坚持 文档编号:3598718 上传时间:2019-06-20 格式:DOC 页数:14 大小:111KB
下载 相关 举报
C语言考试改错填空编程题题库·.doc_第1页
第1页 / 共14页
C语言考试改错填空编程题题库·.doc_第2页
第2页 / 共14页
C语言考试改错填空编程题题库·.doc_第3页
第3页 / 共14页
C语言考试改错填空编程题题库·.doc_第4页
第4页 / 共14页
C语言考试改错填空编程题题库·.doc_第5页
第5页 / 共14页
点击查看更多>>
资源描述

1、 1改错题1、在考生文件夹下,给定程序 MODI.C 的功能是:从低位开始取出长整型变量 s 中奇数位上的数,依次构成一个新数放在 t 中。例如,当 s 中的数为:7654321时,t 中的数为:7531。请修改并运行该程序,然后将源程序文件 MODI.C 上传。#include #include main( ) long s, t, sl=10;clrscr();printf(“nPlease enter s:“); scanf(“%ld“, /*found*/t = s / 10; s%10while ( s 0) s = s/100;t = s%10 * sl + t;/*found*/

2、sl = sl*100 ;printf(“The result is: %ldn“, t);2、在考生文件夹下,给定程序 MODI.C 的功能是:求一维数组 a 中的值为偶数的元素之和。例如,当一维数组 a 中的元素为:10,4,2,7,3,12,5,34,5,9 ,程序的输出应为:The result is: 62#include #include main() int a10=10,4,2,7,3,12,5,34,5,9,i,s;clrscr();s = 0;for ( i=0; i#include sum ( int arr ,int n ) int i,s;clrscr();2s =

3、0;for ( i=0; i#include main() int a33=4,4,34,7,3,12,5,6,5,i,j,max;clrscr();max = a00;for ( i=0; i aij)/*found*/max = aij;printf(“The max is: %dn“, max);5、在考生文件夹下,给定程序 MODI.C 的功能是:求一维数组 a 中的最大元素及其下标。例如,当一维数组 a 中的元素为:1,4,2,7,3,12,5,34,5,9,程序的输出应为:The max is: 34,pos is: 7 。#include #include main() int

4、a10=1,4,2,7,3,12,5,34,5,9,i,max,pos;clrscr();max = a0;pos = 0;for ( i=1; i ai)max = ai;/*found*/i = pos;printf(“The max is: %d ,pos is: %dn“, max , pos);6、在考生文件夹下,给定程序 MODI.C 的功能是:输出 11000 之间的所有完数,并输出每个完数的所有因子。所谓完数,就是指一个正整数,它的各因数之和等于其自身。例如,28=1+2+4+7+14,28 是一个完数。#include #include #include #include m

5、ain() int i,j, t;clrscr();for(i=1;i#include #include main() char s80, t80;/*found*/4int i;clrscr();printf(“nPlease enter string s:“); scanf(“%s“, s);sl = strlen(s);for (i=0; i#include #include main() char s80,t80;int i, sl;clrscr();printf(“nPlease enter string s:“); scanf(“%s“, s);sl = strlen(s);/*f

6、ound*/for( i=0; i#include main( ) /*found*/int a, b,c;5clrscr();printf ( “Enter a scanf (“%lf%lf“, /*found*/c= sqr(a)+sqr(b) ;printf (“c= %f n“, c); 10、在考生文件夹下,给定程序 MODI.C 的功能是:输出 200300 之间的所有素数,要求每行输出 8 个素数。#include #include #include #include main() int m,j,n=0,k;clrscr();for(m=200;mk) if(n%8=0) pr

7、intf(“n“);/*found*/printf(“%6d“,j);n+;11、输出 100200 之间既不能被 3 整除也不能被 7 整除的整数并统计这些整数的个数,要求每行输出 8 个数。#include #include #include #include main() int i;/*found*/int n;clrscr(); for(i=100;i#include #include #include main() int i,j,k;clrscr();/*found*/for(i=1;i#include #include #include main()/*found*/ long

8、 int s,t;int n;s=0;t=1;clrscr();/*found*/for(n=1;n#include main() int arr10=11,4,2,7,3,12,5,34,5,9,i;int s=0;clrscr();/*found*/for ( i=1; i#include double average( int arr , int n ) int k=0,i; double s;s = 0;for ( i=0 ;i#define M 11 main() int aM,i;clrscr();for(i=0;i#include #include long int fun(in

9、t x)long int s=1; int i;for (i=1;i#include main( )int num,k;clrscr() ;/*found*/_(1)_; k=0printf(“Please enter a number:“) ;scanf(“%d“,do/*found*/k=_(2)_ ; k+num%10num/=10; while(num) ;printf(“n%dn“,k) ;106、从键盘上输入一个正整数 n,计算并输出 n 的阶乘。例如,如果从键盘上输入 8,程序的运行结果应为:The result is: 40320。#include #include #include long fac( int n ) int i;long t=1;for( i=2;i#include #include long int fun(int x ,int y )

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

当前位置:首页 > 教育教学资料库 > 参考答案

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。