[计算机类试卷]国家二级(C语言)机试模拟试卷263及答案与解析.doc

上传人:bonesoil321 文档编号:503013 上传时间:2018-11-29 格式:DOC 页数:5 大小:30KB
下载 相关 举报
[计算机类试卷]国家二级(C语言)机试模拟试卷263及答案与解析.doc_第1页
第1页 / 共5页
[计算机类试卷]国家二级(C语言)机试模拟试卷263及答案与解析.doc_第2页
第2页 / 共5页
[计算机类试卷]国家二级(C语言)机试模拟试卷263及答案与解析.doc_第3页
第3页 / 共5页
[计算机类试卷]国家二级(C语言)机试模拟试卷263及答案与解析.doc_第4页
第4页 / 共5页
[计算机类试卷]国家二级(C语言)机试模拟试卷263及答案与解析.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级( C语言)机试模拟试卷 263及答案与解析 一、程序填空题( 30分) 1 从键盘输入一组无符号整数并保存在数组 xxM中,以整数 0结束输入,即第M+1个数是 0(共 M个数据 ),数与数之间以 Enter键分隔,要求这些数的最大位数不超过 4位,其元素的个数通过变量 num传入函数 proc()。请补充函数 proc(),该函数的功能是:从数组 xx中找出十位和百位的数字之和大于 5的所有无符号整数,结果保存在数组 YY中,其个数由函数 proc()返回。 例如,当 xx8=3 637 369 421 35 7334 54 67时, bb4=637 369 421 7334 67

2、)。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc()的横线上填入所编写的若干表达式或语句。 试题程序: #include #define M 1000 int proc(int xx, int bb, int num) int i, n=0; int g, s; for(i=0; i5) 【 2】 ; return 【 3】; void main() int xxM; int yyM; int num=0, n=0, i=0; printf(“Input number: n“); do scanf(“ u“, /*found*/ else

3、if ( k=0 ) return 1L; main() int k = 10 ; printf(“%d!=%ldn“, k, fun (k); 三、程序设计题( 40分) 3 请编写函数 fun,函数的功能是:将大于形参 m且紧靠 m的 k个素数存入 xx所指的数组中。例如 ,若输入 17, 5,则应输出: 19, 23, 29, 31, 37。 注意:部分源程序在文件 PROGl C文件中。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 #include void fun(inL m, int k, int xx) Nain() int

4、In, n, zz1000; void NONO(); printf(“ nPlease enter two integers: “); scanf(“ d d“, &m, &n); fun(m, n, zz); for(m=0; m0) else if ( k=0 ) 【试题解析】 ( 1)第一个标识下的 if语句的条件表达式,根据 C语言的基本语法条件,表达式应该用括号括起来,所以将 “if k0”改为 “if(k0)”。 ( 2)第二个标识下 “else if ( k=0 )”判断 k是否等于 0,在 C语言中, “=”表示等于,而 “=”表示赋值,故第二个标识处应为 “else if ( k=0 )”。 三、程序设计题( 40分) 3 【正确答案】 int r=0, temp, P, sign=1; for(temp=m+1; temp=temp) 【试题解析】 进入 fun函数,根据前面的分析: 首先,定义、初始化变量 sign,作为素数的标志;定义 r,初始化为存储素数数组的起始位。 然后,每判断一次 temp中的值是否为素数后,使 temp的值增 1,再次对 temp中新的值进行判断其是否为素数,不断循环此过程,直到 m的值等于指定的个数,即函数中的 k个数。

展开阅读全文
相关资源
猜你喜欢
  • BS PD ISO TS 17865-2016 Geometrical product specifications (GPS) Guidelines for the evaluation of coordinate measuring machine (CMM) test uncertainty for CMMs using single and mult.pdf BS PD ISO TS 17865-2016 Geometrical product specifications (GPS) Guidelines for the evaluation of coordinate measuring machine (CMM) test uncertainty for CMMs using single and mult.pdf
  • BS PD ISO TS 17951-1-2016 Water quality Determination of fluoride using flow analysis (FIA and CFA) Method using flow injection analysis (FIA) and spectrometric detection after off.pdf BS PD ISO TS 17951-1-2016 Water quality Determination of fluoride using flow analysis (FIA and CFA) Method using flow injection analysis (FIA) and spectrometric detection after off.pdf
  • BS PD ISO TS 17951-2-2016 Water quality Determination of fluoride using flow analysis (FIA and CFA) Method using continuous flow analysis (CFA) with automated in-line distillation《.pdf BS PD ISO TS 17951-2-2016 Water quality Determination of fluoride using flow analysis (FIA and CFA) Method using continuous flow analysis (CFA) with automated in-line distillation《.pdf
  • BS PD ISO TS 18530-2014 0776 Health Informatics Automatic identification and data capture marking and labelling Subject of care and individual provider identification《健康信息学 自动识别和数据.pdf BS PD ISO TS 18530-2014 0776 Health Informatics Automatic identification and data capture marking and labelling Subject of care and individual provider identification《健康信息学 自动识别和数据.pdf
  • BS PD ISO TS 18790-1-2015 Health informatics Profiling framework and classification for Traditional Medicine informatics standards development Traditional Chinese Medicine《健康信息学 传统.pdf BS PD ISO TS 18790-1-2015 Health informatics Profiling framework and classification for Traditional Medicine informatics standards development Traditional Chinese Medicine《健康信息学 传统.pdf
  • BS PD ISO TS 19006-2016 Nanotechnologies 5-(and 6)-Chloromethyl-2' 7' Dichlorodihydrofluorescein diacetate (CM-H2DCF- DA) assay for evaluating nanoparticle-induced intracellular re.pdf BS PD ISO TS 19006-2016 Nanotechnologies 5-(and 6)-Chloromethyl-2' 7' Dichlorodihydrofluorescein diacetate (CM-H2DCF- DA) assay for evaluating nanoparticle-induced intracellular re.pdf
  • BS PD ISO TS 19425-2015 Reciprocating internal combustion engines Measurement method for air cleaners Sound power level of combustion air inlet noise and insertion loss using sound.pdf BS PD ISO TS 19425-2015 Reciprocating internal combustion engines Measurement method for air cleaners Sound power level of combustion air inlet noise and insertion loss using sound.pdf
  • BS PD ISO TS 19590-2017 Nanotechnologies -- Size distribution and concentration of inorganic nanoparticles in aqueous media via single particle inductively coupled plasma mass spec.pdf BS PD ISO TS 19590-2017 Nanotechnologies -- Size distribution and concentration of inorganic nanoparticles in aqueous media via single particle inductively coupled plasma mass spec.pdf
  • BS PD ISO TS 21219-1-2016 Intelligent transport systems Traffic and travel information (TTI) via transport protocol experts group generation 2 (TPEG2) Introduction numbering and ve.pdf BS PD ISO TS 21219-1-2016 Intelligent transport systems Traffic and travel information (TTI) via transport protocol experts group generation 2 (TPEG2) Introduction numbering and ve.pdf
  • 相关搜索

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

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