【计算机类职业资格】二级C语言-324 (1)及答案解析.doc

上传人:ownview251 文档编号:1325213 上传时间:2019-10-17 格式:DOC 页数:6 大小:32KB
下载 相关 举报
【计算机类职业资格】二级C语言-324 (1)及答案解析.doc_第1页
第1页 / 共6页
【计算机类职业资格】二级C语言-324 (1)及答案解析.doc_第2页
第2页 / 共6页
【计算机类职业资格】二级C语言-324 (1)及答案解析.doc_第3页
第3页 / 共6页
【计算机类职业资格】二级C语言-324 (1)及答案解析.doc_第4页
第4页 / 共6页
【计算机类职业资格】二级C语言-324 (1)及答案解析.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、二级 C 语言-324 (1)及答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.请补充函数 proc(),该函数的功能是:求能整除 x 且是奇数的数,把这些数保存在数组 bb 中,并按从大到小的顺序输出。 例如,当 x=15 时,依次输出:15 5 3 1。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc()的横线上填入所编写的若干表达式或语句。 试题程序: #includestdlib.h #includeconio.h #includestdio.h void proc(int x, i

2、nt bb) int i; int j=0; for( 1; i=x; i+=2) if( 2) bbj+=i; printf(“/n/n“); for(i= 3; i=0; i-) printf(“%d“, bbi); void main() int k=1; int str100; system(“CLS“); printf(“/nPlease input X=“); scanf(“%d“, proc(k, str); (分数:30.00)二、程序改错题(总题数:1,分数:40.00)2.下列给定程序中,函数 proc()的功能是求出数组中最小数和次最小数,并把最小数和 arr0中的数对调

3、次最小数和 arr1中的数对调。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动 main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #includestdio.h #includeconio.h #includestdio.h #define M 20 void proc(int *arr, int n) int i, m, t, k; /*found* for(i=0; in; i+) m=i; for(k=i; kn; k+) if(arrkarrm) /*found* k=m; t=arri; arri=arrm; arrm=t; void main()

4、int bM=11, 5, 12, 0, 3, 6, 9, 7, 10, 8, n=10, i; system(“CLS“); for(i=0; in; i+) printf(“%d“, bi); printf(“/n“); proc(b, n); for(i=0; in; i+) printf(“%d“, bi); printf(“/n“); (分数:40.00)_三、程序设计题(总题数:1,分数:30.00)3.请编写函数 proc(),其功能是:将所有大于 1 小于整数 m 的非素数存入 xx 所指数组中,非素数的个数通过 k 传回。 例如,输入 20,则应输出 4 6 8 9 10 1

5、2 14 15 16 18。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc()的花括号中填入所编写的若干语句。 试题程序: #includestdlib.h #includeconio.h #includestdio.h void proc(int m,int*k,int xx) void main() int m, n, str100; system(“CLS“); printf(“/nPlease enter an integer number between 10 and 100: “); scanf(“%d“, proc(n, pri

6、ntf(“/n/nThere are %d non-prime numbers less than%d: “, m, n); for(n=0; nm; n+) printf(“/n%4d“, strn); (分数:30.00)_二级 C 语言-324 (1)答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.请补充函数 proc(),该函数的功能是:求能整除 x 且是奇数的数,把这些数保存在数组 bb 中,并按从大到小的顺序输出。 例如,当 x=15 时,依次输出:15 5 3 1。 注意:部分源程序给出如下。 请勿改动 main()函数和其他

7、函数中的任何内容,仅在函数 proc()的横线上填入所编写的若干表达式或语句。 试题程序: #includestdlib.h #includeconio.h #includestdio.h void proc(int x, int bb) int i; int j=0; for( 1; i=x; i+=2) if( 2) bbj+=i; printf(“/n/n“); for(i= 3; i=0; i-) printf(“%d“, bbi); void main() int k=1; int str100; system(“CLS“); printf(“/nPlease input X=“);

8、 scanf(“%d“, proc(k, str); (分数:30.00)解析:i=1 x%i=0 /*found* for(i=0; in; i+) m=i; for(k=i; kn; k+) if(arrkarrm) /*found* k=m; t=arri; arri=arrm; arrm=t; void main() int bM=11, 5, 12, 0, 3, 6, 9, 7, 10, 8, n=10, i; system(“CLS“); for(i=0; in; i+) printf(“%d“, bi); printf(“/n“); proc(b, n); for(i=0; in

9、 i+) printf(“%d“, bi); printf(“/n“); (分数:40.00)_正确答案:()解析:(1)错误:for(i=0; in; i+) 正确:for(i=0; i2; i+) (2)错误:k=m; 正确:m=k; 解析 题目中要求将数组中最小的和次最小的元素,与数组中第一个和第二个元素相交换,因此,“for(i=0; in; i+)”应改为“for(i=0; i2; i+)”;由函数 proc()可知,变量 m 中存放最大元素的下标,因此,“k=m;”应改为“m=k;”。三、程序设计题(总题数:1,分数:30.00)3.请编写函数 proc(),其功能是:将所有大于

10、 1 小于整数 m 的非素数存入 xx 所指数组中,非素数的个数通过 k 传回。 例如,输入 20,则应输出 4 6 8 9 10 12 14 15 16 18。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc()的花括号中填入所编写的若干语句。 试题程序: #includestdlib.h #includeconio.h #includestdio.h void proc(int m,int*k,int xx) void main() int m, n, str100; system(“CLS“); printf(“/nPlease ente

11、r an integer number between 10 and 100: “); scanf(“%d“, proc(n, printf(“/n/nThere are %d non-prime numbers less than%d: “, m, n); for(n=0; nm; n+) printf(“/n%4d“, strn); (分数:30.00)_正确答案:()解析:void proc(int m, int*k, int xx) int i, j, n=0; for(i=4; im; i+) for(j=2; ji; j+) /判断其是否为素数 if(i%j=0)break; if(ji)x xn+=i; /所有大于 1 小于整数 m 的非素数存入 xx 所指数组中 *k=n; /非素数的个数通过 k 传回 解析 题目中要求将所有大于 1 小于整数 m 的非素数存入 xx 所指数组中,因此需要判断所有大于 1 小于 m 的整数是否为素数。将所有大于 1 小于 m 的非素数放入数组 xx 中,并将非素数的个数通过形参 k 传递回主函数中。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN ISO 11439-2013 Gas cylinders - High pressure cylinders for the on-board storage of natural gas as a fuel for automotive vehicles (ISO 11439 2013) German version EN ISO 11439.pdf DIN EN ISO 11439-2013 Gas cylinders - High pressure cylinders for the on-board storage of natural gas as a fuel for automotive vehicles (ISO 11439 2013) German version EN ISO 11439.pdf
  • DIN EN ISO 11442-2006 Technical product documentation - Document management (ISO 11442 2006) English version of DIN EN ISO 11442 2006-06《技术产品文件 文献管理》.pdf DIN EN ISO 11442-2006 Technical product documentation - Document management (ISO 11442 2006) English version of DIN EN ISO 11442 2006-06《技术产品文件 文献管理》.pdf
  • DIN EN ISO 11461-2014 Soil quality - Determination of soil water content as a volume fraction using coring sleeves - Gravimetric method (ISO 11461 2001) German version EN ISO 11461.pdf DIN EN ISO 11461-2014 Soil quality - Determination of soil water content as a volume fraction using coring sleeves - Gravimetric method (ISO 11461 2001) German version EN ISO 11461.pdf
  • DIN EN ISO 11463-2008 Corrosion of metals and alloys - Evaluation of pitting corrosion (ISO 11463 1995) German version EN ISO 11463 2008《金属和合金的腐蚀 点蚀评估》.pdf DIN EN ISO 11463-2008 Corrosion of metals and alloys - Evaluation of pitting corrosion (ISO 11463 1995) German version EN ISO 11463 2008《金属和合金的腐蚀 点蚀评估》.pdf
  • DIN EN ISO 11468-1999 Plastics - Preparation of PVC pastes for test purposes - Dissolver method (ISO 11468 1997) German version EN ISO 11468 1999《塑料 聚氯乙烯(PVC)糊剂试样制备 溶解器法》.pdf DIN EN ISO 11468-1999 Plastics - Preparation of PVC pastes for test purposes - Dissolver method (ISO 11468 1997) German version EN ISO 11468 1999《塑料 聚氯乙烯(PVC)糊剂试样制备 溶解器法》.pdf
  • DIN EN ISO 11469-2017 Plastics - Generic identification and marking of plastics products (ISO 11469 2016) German version EN ISO 11469 2016《塑料 塑料产品通用标识和标记(ISO 11469-2016) 德文版本EN ISO.pdf DIN EN ISO 11469-2017 Plastics - Generic identification and marking of plastics products (ISO 11469 2016) German version EN ISO 11469 2016《塑料 塑料产品通用标识和标记(ISO 11469-2016) 德文版本EN ISO.pdf
  • DIN EN ISO 11474-2014 Corrosion of metals and alloys - Corrosion tests in artificial atmosphere - Accelerated outdoor test by intermittent spraying of a salt solution (Scab test) (.pdf DIN EN ISO 11474-2014 Corrosion of metals and alloys - Corrosion tests in artificial atmosphere - Accelerated outdoor test by intermittent spraying of a salt solution (Scab test) (.pdf
  • DIN EN ISO 11489-1995 Determination of platinum in platinum jewellery alloys - Gravimetric method after reduction with mercury(I) chloride (ISO 11489 1995) German version EN ISO 11.pdf DIN EN ISO 11489-1995 Determination of platinum in platinum jewellery alloys - Gravimetric method after reduction with mercury(I) chloride (ISO 11489 1995) German version EN ISO 11.pdf
  • DIN EN ISO 11490-2016 Jewellery - Determination of palladium in palladium jewellery alloys - Gravimetric determination with dimethylglyoxime (ISO 11490 2015) German version EN ISO .pdf DIN EN ISO 11490-2016 Jewellery - Determination of palladium in palladium jewellery alloys - Gravimetric determination with dimethylglyoxime (ISO 11490 2015) German version EN ISO .pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1