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

上传人:visitstep340 文档编号:498174 上传时间:2018-11-28 格式:DOC 页数:6 大小:33KB
下载 相关 举报
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷245及答案与解析.doc_第1页
第1页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷245及答案与解析.doc_第2页
第2页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷245及答案与解析.doc_第3页
第3页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷245及答案与解析.doc_第4页
第4页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷245及答案与解析.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、国家二级 C语言机试(操作题)模拟试卷 245及答案与解析 一、程序填空题 1 给定程序中,函数 fun的功能是:调用随机函数产生 20个互不相同的整数放在形参 a所指数组中 (此数组在主函数中已置 0)。 请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。 注意:部分源程序在文件 BLANK1 C中。 不得增行或删行,也不得更改程序的结构 ! 试题程序: 1 #include stdlib h 2 #include stdio h 3 #define N 20 4 void fun(int*a) 5 int i, x, n=0; 6 x=rand() 20; 7 *fou

2、nd* 8 while(n 【 1】 ) 9 for(i=0; i n; i+) 10 *found* 11 i f(x=ai) 12 【 2】 ; 13 *found* 14 if(i=【 3】 ) 15 an=x ; n+; 16 x=rand() 20; 17 18 19 main() 20 int xN=0, i; 21 fun(x); 22 printf(The result: n); 23 for(i=0; i N; i+) 24 printf( 4 d, xi); 25 if(i+1) 5=0)printf( n); 26 27 printf( n n); 28 二、程序修改题

3、2 下列给定函数中,函数 fun的功能是:统计字符串中各元音字母 (即 A、 E、 I、O、 U)的个数。注意:字母不分大小写。 例如,输入 THIs is a boot,则应输出是 1 0 2 2 0。 请改正程序中的错误,使它能得出正确的结果。 注意:部分源程序在文件 MODI1 C中,不要改动 main函数,不得增行或删行,也不得更改程序的结构 ! 试题程序: 1 #include stdlib h 2 #include conio h 3 #include stdio h 4 *found* 5 fun(char*s, int num5) 6 int k, i=5; 7 for(k=0

4、 k=0) 26 numi+; 27 28 29 void main() 30 char s181; int num15, i; 31 system(CLS); 32 printf ( nPlease enter a string: ); 33 gets(s1); 34 fun(s1, num1); 35 for(i=0; i=100) 8 b10+; *如果年龄大于等于 100, b10自增 1* 9 else 10 bai 10+; *如果年龄小于 100,则将其分别统计到 bai 10中 * 11 【试题解析】 本题是一个分段函数的问题,用两个循环米完成。第 1个循环的作用是使 b中的所有元素值都为 0。这个循环不能省略,因为若未对 b中的元素赋初值,则它们的值是不可预测的。第 2个循环的作用是分别统计 a中各年龄段的人数。当 ai100时,按题意要将其统计到 h10中 。 else的作用是如果年龄小于100,则将其分别统计到 bai 10中。由运算优先级可知先进行 ai 10的运算,所得结果作为 h的下标。若 ai为 0 9时, ai 10的值为 0,且 0 9岁的人数正好要存入 b0中。若 ai为 10 19时, ai 10的值为 1,且 10 19岁的人数正好要存入 b1中,依此类推。

展开阅读全文
相关资源
猜你喜欢
  • BS PD ISO PAS 12835-2013 3965 Qualification of casing connections for thermal wells《热采井用套管连接的鉴定》.pdf BS PD ISO PAS 12835-2013 3965 Qualification of casing connections for thermal wells《热采井用套管连接的鉴定》.pdf
  • BS PD ISO PAS 15339-1-2015 Graphic technology Printing from digital data across multiple technologies Principles《印刷技术 多技术的数字数据打印 原理》.pdf BS PD ISO PAS 15339-1-2015 Graphic technology Printing from digital data across multiple technologies Principles《印刷技术 多技术的数字数据打印 原理》.pdf
  • BS PD ISO PAS 15339-2-2015 Graphic technology Printing from digital data across multiple technologies Characterized reference printing conditions CRPC1-CRPC7《印刷技术 多技术的数字数据打印 有特征的参考印刷条件 CRPC1-CRPC7.pdf BS PD ISO PAS 15339-2-2015 Graphic technology Printing from digital data across multiple technologies Characterized reference printing conditions CRPC1-CRPC7《印刷技术 多技术的数字数据打印 有特征的参考印刷条件 CRPC1-CRPC7.pdf
  • BS PD ISO PAS 19295-2016 Electrically propelled road vehicles Specification of voltage sub-classes for voltage class B《电动道路车辆 用于电压等级B的电压子类规格》.pdf BS PD ISO PAS 19295-2016 Electrically propelled road vehicles Specification of voltage sub-classes for voltage class B《电动道路车辆 用于电压等级B的电压子类规格》.pdf
  • BS PD ISO PAS 19450-2015 Automation systems and integration Object-Process Methodology《自动化系统和集成 对象过程方法》.pdf BS PD ISO PAS 19450-2015 Automation systems and integration Object-Process Methodology《自动化系统和集成 对象过程方法》.pdf
  • BS PD ISO PAS 19451-1-2016 Application of ISO 26262 2011-2012 to semiconductors Application of concepts《ISO 26262-2011-2012半导体应用 概念应用》.pdf BS PD ISO PAS 19451-1-2016 Application of ISO 26262 2011-2012 to semiconductors Application of concepts《ISO 26262-2011-2012半导体应用 概念应用》.pdf
  • BS PD ISO PAS 19451-2-2016 Application of ISO 26262 2011-2012 to semiconductors Application of hardware qualification《ISO 26262-2011-2012半导体应用 硬件认证应用》.pdf BS PD ISO PAS 19451-2-2016 Application of ISO 26262 2011-2012 to semiconductors Application of hardware qualification《ISO 26262-2011-2012半导体应用 硬件认证应用》.pdf
  • BS PD ISO PAS 19695-2015 Motorcycles Functional safety《摩托车 功能安全》.pdf BS PD ISO PAS 19695-2015 Motorcycles Functional safety《摩托车 功能安全》.pdf
  • BS PD ISO PAS 20065-2016 Acoustics Objective method for assessing the audibility of tones in noise Engineering method《声学 利用客观法评定声音音调的可听度 工程方法》.pdf BS PD ISO PAS 20065-2016 Acoustics Objective method for assessing the audibility of tones in noise Engineering method《声学 利用客观法评定声音音调的可听度 工程方法》.pdf
  • 相关搜索

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

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