【计算机类职业资格】计算机二级(C)上机考试18及答案解析.doc

上传人:hopesteam270 文档编号:1337765 上传时间:2019-10-17 格式:DOC 页数:2 大小:30.50KB
下载 相关 举报
【计算机类职业资格】计算机二级(C)上机考试18及答案解析.doc_第1页
第1页 / 共2页
【计算机类职业资格】计算机二级(C)上机考试18及答案解析.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

1、计算机二级(C)上机考试 18 及答案解析(总分:-3.00,做题时间:120 分钟)1.填空题 请补充 main 函数,该函数的功能是:从一个字符串中截取前面若干个给定长度的子字符串。其中,str1 指向原字符串,截取后的字符存放在 str2 所指的字符数组中,n 中存放需截取的字符个数。 例如:当 str1=“cdefghij”,然后输入 4,则 str2=“cdef”。 注意:部分源程序给出如下。 请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include #include #define LEN 80 ma

2、in() char str1LEN,str2LEN; int n,i; clrscr(); printf(“Enter the string:/n“); gets(str1); printf(“Enter the position of the string deleted:“); scanf(【1】); for(i=0;i_2.改错题 下列给定程序中,函数 fun()的功能是计算并输出 high 以内的素数之和。high 由主函数传给fun()函数。若 high 的值为 100,则函数的值为 1060。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动 main 函数,不得增行或删行

3、也不得更改程序的结构。 试题程序: #include #include #include int fun(int high) int sum=0,n=0, j, yes; while(high=2) yes = 1; for(j=2; j=2) yes = 1; for(j=2; j=high/2; j+) /*found*/ ifhigh%j=0 yes=0; break; /*found*/ if(yes=0) sum+=high; n+; high-; return sum; main() clrscr(); printf(“%d/n“,fun(100); (分数:-1.00)_正确答

4、案:((1)错误:ifhigh%j=0 正确:if(high%j=0) (2)错误:if(yes=0) 正确:if(yes) )解析:错误 1:if 语句的两侧要加括号。 错误 2:yes 为 1 时,说明被判断的数为素数,要加入总和。 3.编程题 请编写一个函数 void fun(int m, int k, int xx),该函数的功能是:将大于整数 m 且紧靠 m 的 k 个非素数存入所指的数组中。 例如,若输入 15,5,则应输出 16,18,20,21,22。 注意:部分源程序给出如下。 请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun 的花括号中填入所编写的若干语句。 试题程序: #include #include void fun(int m, int k, int xx) main() int m,n,zz1000; clrscr(); printf(“/nPlease enter two integers: “); scanf(“%d%d“, fun(m, n, zz); for(m=0;m_正确答案:(void fun(int m, int k, int xx) int i,j,n; for(i=m+1,n=0;n解析:本题只要掌握了判断非素数和素数的算法即不难完成了,其实程序缺少部分也正是这部分。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 2526-1983 Titanium TI-P02 390 MPa Less Than Rm Less Than or Equal to 540 MPa Sheets and Strips a Less Than or Equal to 5 mm Aerospace Series Edition 1《航空航天系列.钛片和带TI-P04 .pdf AECMA PREN 2526-1983 Titanium TI-P02 390 MPa Less Than Rm Less Than or Equal to 540 MPa Sheets and Strips a Less Than or Equal to 5 mm Aerospace Series Edition 1《航空航天系列.钛片和带TI-P04 .pdf
  • AECMA PREN 2527-1983 Titanium TI-P04 570 MPa Less Than Rm Less Than or Equal to 730 MPa Sheets and Strips a Less Than or Equal to 5 mm Aerospace Series Edition 1《航空航天系列钛片和带TI-P04 5.pdf AECMA PREN 2527-1983 Titanium TI-P04 570 MPa Less Than Rm Less Than or Equal to 730 MPa Sheets and Strips a Less Than or Equal to 5 mm Aerospace Series Edition 1《航空航天系列钛片和带TI-P04 5.pdf
  • AECMA PREN 2528-1983 Titanium Alloy TI-P11 540 MPa Less Than Rm Less Than or Equal to 700 MPa Sheets and Strips a Less Than or Equal to 5 mm Aerospace Series Edition 1《航空航天系列钛合金片和带.pdf AECMA PREN 2528-1983 Titanium Alloy TI-P11 540 MPa Less Than Rm Less Than or Equal to 700 MPa Sheets and Strips a Less Than or Equal to 5 mm Aerospace Series Edition 1《航空航天系列钛合金片和带.pdf
  • AECMA PREN 2530-1994 Titanium Alloy TI-P63 Annealed - 900 MPa Less Than or Equal to Rm Less Then or Equal to 1160 MPa Bars De Less Than or Equal to 150 mm Aerospace Series Edition .pdf AECMA PREN 2530-1994 Titanium Alloy TI-P63 Annealed - 900 MPa Less Than or Equal to Rm Less Then or Equal to 1160 MPa Bars De Less Than or Equal to 150 mm Aerospace Series Edition .pdf
  • AECMA PREN 2531-1983 Titanium Alloy TI-P63 Annealed - 900 MPa Less Than or Equal to Rm Less Than or Equal to 1160 MPa Forgings De Less Than or Equal to 150 mm Aerospace Series Edit.pdf AECMA PREN 2531-1983 Titanium Alloy TI-P63 Annealed - 900 MPa Less Than or Equal to Rm Less Than or Equal to 1160 MPa Forgings De Less Than or Equal to 150 mm Aerospace Series Edit.pdf
  • AECMA PREN 2532-1984 Titanium Alloy TI-P68 - 1100 Less Than or Equal to Rm Less Than or Equal to 1280 MPa Bar De Less Than or Equal to 25 mm Aerospace Series Edition 1《航空航天系列钛合金棒材T.pdf AECMA PREN 2532-1984 Titanium Alloy TI-P68 - 1100 Less Than or Equal to Rm Less Than or Equal to 1280 MPa Bar De Less Than or Equal to 25 mm Aerospace Series Edition 1《航空航天系列钛合金棒材T.pdf
  • AECMA PREN 2533-1984 Titanium alloy TI-P68 1050 Less Than or Equal to Rm Less Than or Equal to 1220 MPa Bar 25 Less Than De Less Than or Equal to 100 mm Aerospace Series Edition 1《.pdf AECMA PREN 2533-1984 Titanium alloy TI-P68 1050 Less Than or Equal to Rm Less Than or Equal to 1220 MPa Bar 25 Less Than De Less Than or Equal to 100 mm Aerospace Series Edition 1《.pdf
  • AECMA PREN 2534-1984 Titanium Alloy TI-P68 1000 Less Than or Equal to Rm Less Than or Equal to 1200 MPa Bar 100 Less Than De Less Than or Equal to 150 mm Aerospace Series Edition 1.pdf AECMA PREN 2534-1984 Titanium Alloy TI-P68 1000 Less Than or Equal to Rm Less Than or Equal to 1200 MPa Bar 100 Less Than De Less Than or Equal to 150 mm Aerospace Series Edition 1.pdf
  • AECMA PREN 2535-1994 Aerospace Series Vacuum Deposition of Cadmium Edition P 1《航空航天系列.镉真空沉淀 P.第1版》.pdf AECMA PREN 2535-1994 Aerospace Series Vacuum Deposition of Cadmium Edition P 1《航空航天系列.镉真空沉淀 P.第1版》.pdf
  • 相关搜索

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

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