python123程序改错题库,2016最新二级C语言考试题库及答案(程序改错专项练习 精华版)...

《2016最新二级C语言考试题库及答案(程序改错专项练习 精华版)》由会员分享,可在线阅读,更多相关《2016最新二级C语言考试题库及答案(程序改错专项练习 精华版)(4页珍藏版)》请在人人文库网上搜索。

1、程序改错题(共15题)1、在考生文件夹下,给定程序MODI.C的功能是:求一维数组a中所有元素的平均值,结果保留两位小数。例如,当一维数组a中的元素为:10,4,2,7,3,12,5,34,5,9程序的输出应为:The aver is: 9.10 。#include #include void main()int a10=10,4,2,7,3,12,5,34,5,9,i;float aver,s;/*found*/int aver,s;/*found*/s=a0;s = 0;for ( i=1; i#include void main()int a33=4,4,34,37,3,12,5,6,5。

2、,i,j,max,min;max = min = a00;for ( i=0; iaij)if (min #include void main()int a10=1,4,2,7,3,12,5,34,5,9,i,max,pos;max = a0;pos = 0;for ( i=1; i ai)max = ai;/*found*/pos=i;i = pos;printf(The max is: %d ,pos is: %dn, max , pos);4、在考生文件夹下,给定程序MODI.C的功能是:求二维数组a中的最小值。例如,当二维数组a中的元素为:4 2 347 3 125 6 5程序的输出应。

3、为:The min is: 2 。#include #include void main()int a33=4,2,34,7,3,12,5,6,5,i,j,min;min = a00;for(i=0;i aij)/*found*/min=aij;min = aij;printf(The min is: %dn, min);5、在考生文件夹下,给定程序MODI.C的功能是:求一维数组a中所有元素的平均值。例如,当一维数组a中的元素为:10,4,2,7,3,12,5,34,5,9程序的输出应为:The aver is: 9.10 。#include #include void main()int 。

4、a10=10,4,2,7,3,12,5,34,5,9,i;double aver,s;s = a0;for ( i=1; i#include #include #include void main()int score,t;printf(Please enter a score:);doscanf(%d,&score);while(score100);t=score/10;switch(t)/*found*/switch(score)case 10:case 9:printf(优秀!n);break;case 8:printf(良好!n);break;case 7:printf(中等!n);b。

5、reak;case 6:printf(及格!n);break;/*found*/else :printf(不及格!n);default: printf(不及格!n);7、在考生文件夹下,给定程序MODI.C的功能是:输出100200之间既不能被3整除也不能被7整除的整数并统计这些整数的个数,要求每行输出8个数。#include #include #include #include void main()int i;/*found*/int n=0;int n;for(i=100;imain() int score,sum=0;int i,n=0;for(i=1;i=88) n+;/*found。

6、*/if(score=450 | n=5 )/*found*/if(sum=450 & n=5 )printf(The student is very good!n);else printf(The student is not very good!n);9、在考生文件夹下,给定程序MODI.C的功能是:输出200300之间的所有素数,要求每行输出8个素数。#include #include main()int m,j,n=0,k;for(m=200;mk) if(n%8=0) printf(n);/*found*/printf(%d,m);printf(%d,j);n+;10、在考生文件夹下。

7、,给定程序MODI.C的功能是:求出a所指数组中最小数(规定最小数不在a0中),最小数和a0中的数对调。例如数组中原有的数为:7、10、12、0、3、6、9、11、5、8,输出的结果为:0、10、12、7、3、6、9、11、5、8。#include #include #define N 20main( )int aN=7,10,12,0,3,6,9,11,5,8, n=10, i, k,m,min,t;for ( i = 0; imin ) min = ak; m = k;/*found*/t = a0; am=a0; am = t;for ( i=0; i#include main() in。

8、t a10=1,4,2,7,3,12,5,34,5,9,i,min,pos;/*found*/min=a0;min = 0;pos = 0;for ( i=1; i ai)min = ai;/*found*/pos=i;pos = ai;printf(The min is: %d ,pos is: %dn, min , pos);12、在考生文件夹下,给定程序MODI.C的功能是:求一维数组a中值为偶数的元素之和。例如,当一维数组a中的元素为:10,4,2,7,3,12,5,34,5,9 ,程序的输出应为:The result is: 62。#include #include sum ( in。

9、t arr ,int n )int i,s;s = 0;for ( i=0; i#include void main() int a10=1,4,2,7,3,12,5,34,5,9,i,max,pos;max = a0;pos = 0;for ( i=1; i ai)/*found*/max=ai;max = a;pos =i;printf(The max is: %d ,pos is: %dn, max , pos);14、在考生文件夹下,给定程序MODI.C的功能是:求一维数组a中值为奇数的元素之和。例如,当一维数组a中的元素为:10,4,2,7,3,12,5,34,5,9, 21 ,19。

10、程序的输出应为:The result is: 69。#include #include int sum( int b ,int n )int i,s = 0;for ( i=0; i#include int max;maxarr(int arr )int pos,i;/*found*/ max=arr0;max = 0;pos = 0;for ( i=1; i10; i+)if (max arri)max = arri;pos = i;/*found*/return(pos);return (i);main()int a10=34,4,2,7,3,12,5,8,5,9;printf(The max is: %d ,pos is: %dn, max , maxarr(a);。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值