【计算机类职业资格】二级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 传递回主函数中。

展开阅读全文
相关资源
猜你喜欢
  • ITU-R REPORT BT 2017-1998 Stereoscopic Television MPEG-2 Multi-View Profile (7 pp)《MPEG-2多视角的实体镜电视》.pdf ITU-R REPORT BT 2017-1998 Stereoscopic Television MPEG-2 Multi-View Profile (7 pp)《MPEG-2多视角的实体镜电视》.pdf
  • ITU-R REPORT BT 2018-1998 Study of the System C Ghost Cancelling Reference Signal for the Evaluation and Correction of Linear Distortion in the Television Chain (15 pp)《电视连锁中删除参考信号.pdf ITU-R REPORT BT 2018-1998 Study of the System C Ghost Cancelling Reference Signal for the Evaluation and Correction of Linear Distortion in the Television Chain (15 pp)《电视连锁中删除参考信号.pdf
  • ITU-R REPORT BT 2020-1-2000 Objective Quality Assessment Technology in a Digital Environment (4 pp)《数码环境中的客观质量评定技术》.pdf ITU-R REPORT BT 2020-1-2000 Objective Quality Assessment Technology in a Digital Environment (4 pp)《数码环境中的客观质量评定技术》.pdf
  • ITU-R REPORT BT 2025-2000 Progress on Development and Implementation of Interactivity in Broadcasting Systems and Services (Question ITU-R 256 11)《广播和服务系统活动的发展与完善的进程》.pdf ITU-R REPORT BT 2025-2000 Progress on Development and Implementation of Interactivity in Broadcasting Systems and Services (Question ITU-R 256 11)《广播和服务系统活动的发展与完善的进程》.pdf
  • ITU-R REPORT BT 2035-2-2008 Guidelines and techniques for the evaluation of digital terrestrial television broadcasting systems including assessment of their coverage areas《含覆盖范围评估.pdf ITU-R REPORT BT 2035-2-2008 Guidelines and techniques for the evaluation of digital terrestrial television broadcasting systems including assessment of their coverage areas《含覆盖范围评估.pdf
  • ITU-R REPORT BT 2036-2003 The problem of unauthorized redistribution of broadcast content via the internet《通过网络将直播内容非法传播的问题》.pdf ITU-R REPORT BT 2036-2003 The problem of unauthorized redistribution of broadcast content via the internet《通过网络将直播内容非法传播的问题》.pdf
  • ITU-R REPORT BT 2042-4-2010 Technologies in the area of extremely high resolution imagery《在影像极高分辨率区域的技术》.pdf ITU-R REPORT BT 2042-4-2010 Technologies in the area of extremely high resolution imagery《在影像极高分辨率区域的技术》.pdf
  • ITU-R REPORT BT 2043-2004 Analogue television systems currently in use throughout the world《目前世界上使用的模拟电视系统》.pdf ITU-R REPORT BT 2043-2004 Analogue television systems currently in use throughout the world《目前世界上使用的模拟电视系统》.pdf
  • ITU-R REPORT BT 2044-2004 Tolerable round-trip time delay for sound-programme and television broadcast programme inserts C Context and rationale《声音节目和电视广播节目插播的可容忍往返传播延迟时间的 背景和基本原理》.pdf ITU-R REPORT BT 2044-2004 Tolerable round-trip time delay for sound-programme and television broadcast programme inserts C Context and rationale《声音节目和电视广播节目插播的可容忍往返传播延迟时间的 背景和基本原理》.pdf
  • 相关搜索

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

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