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

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

1、计算机二级(C)上机考试 16 及答案解析(总分:-3.00,做题时间:120 分钟)1.填空题 请补充 main 函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。 例如:当 strN=“123 abcdef ABCDEF!”,结果输出:“123 ABCDEF ABCDEF!”。 注意:部分源程序给出如下。 请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun 的横线上填入所编写的若干表达式或语句。 试题程序: #include #include #include #define N 80 void main()

2、 int j; char strN=“ 123abcdef ABCDEF!“; char *pf=str; clrscr(); printf(“*original string */n“); puts(str); 【1】; while(*(pf+j) if(*(pf+j)=a j+; else 【3】; printf(“*new string*/n“); puts(str); system(“pause“); (分数:-1.00)_正确答案:(【1】j=0 【2】*(pf+j)-32 【3】j+ )解析:填空 1:变量 j 声明时没有初始化,而后面程序用到 j,所以在这里对 j 初始化为 0。

3、填空 2:将小写字母转换为对应的大写字母的方法是,小写字母的 ASCII 码减去 32,得到对应的大写字母的 ASCII 码。填空 3:如果当前字符不是小写字母,则不做任何处理,使指针指向下一个字符,准备进行判断。2.改错题 在主函数中从键盘输入若干个数放入数组中,用 0 结束输入并放在最后一个元素中。下列给定程序中,函数 fun()的功能是计算数组元素中值为负数的平均值(不包括 0)。 例如:数组中元素的值依次为 43,-47,-21,53,-8,12,0,则程序的运行结果为-25.333333。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动 main 函数,不得增行或删行,也不

4、得更改程序的结构。 试题程序: #include #include double fun(int x ) double sum=0.0; int c=0, i=0; /*found*/ while(xi=0) if(xi_正确答案:((1)错误:while(xi=0) 正确:while(xi!=0) (2)错误:sum=sum/c; 正确:sum=sum/c; )解析:错误 1:此处考查的是对循环条件的理解,当被判断的数组元素为 0 时,说明这是数组的最后一个元素,此时要跳出循环。 错误 2:C 语言中的除法运算符是“/“,而不是“。 3.编程题 请编写一个函数 void fun(int m,

5、 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解析:本题只要掌握了判断非素数和素数的算法即不难完成了,其实程序缺少部分也正是这部分。

展开阅读全文
相关资源
猜你喜欢
  • BS EN ISO 16231-2-2015 Self-propelled agricultural machinery Assessment of stability Determination of static stability and test procedure《自推进式农业机械 稳定性评估 静态稳定性和测试程序的确定》.pdf BS EN ISO 16231-2-2015 Self-propelled agricultural machinery Assessment of stability Determination of static stability and test procedure《自推进式农业机械 稳定性评估 静态稳定性和测试程序的确定》.pdf
  • BS EN ISO 16251-1-2014 Acoustics Laboratory measurement of the reduction of transmitted impact noise by floor coverings on a small floor mock-up Heavyweight compact floor《声学 使用小楼板模.pdf BS EN ISO 16251-1-2014 Acoustics Laboratory measurement of the reduction of transmitted impact noise by floor coverings on a small floor mock-up Heavyweight compact floor《声学 使用小楼板模.pdf
  • BS EN ISO 16256-2012 Clinical laboratory testing and in vitro diagnostic test systems Reference method for testing the in vitro activity of antimicrobial agents against yeast of fu.pdf BS EN ISO 16256-2012 Clinical laboratory testing and in vitro diagnostic test systems Reference method for testing the in vitro activity of antimicrobial agents against yeast of fu.pdf
  • BS EN ISO 16264-2002 Water quality - Determination of soluble silicates by flow analysis (FIA and CFA) and photometric detection《水质 用流量分析法(FIA 和 CFA)和光度计检测法测定可溶性硅酸盐》.pdf BS EN ISO 16264-2002 Water quality - Determination of soluble silicates by flow analysis (FIA and CFA) and photometric detection《水质 用流量分析法(FIA 和 CFA)和光度计检测法测定可溶性硅酸盐》.pdf
  • BS EN ISO 16265-2012 Water quality Determination of the methylene blue active substances (MBAS) index Method using continuous flow analysis (CFA)《水质 亚甲基蓝活性物质(MBAS)指数的测定 连续流分析(CFA)方.pdf BS EN ISO 16265-2012 Water quality Determination of the methylene blue active substances (MBAS) index Method using continuous flow analysis (CFA)《水质 亚甲基蓝活性物质(MBAS)指数的测定 连续流分析(CFA)方.pdf
  • BS EN ISO 16266-2008 Water quality - Detection and enumeration of Pseudomonas aeruginosa - Method by membrane filtration《水质 绿脓杆菌的检测及计数 膜滤法》.pdf BS EN ISO 16266-2008 Water quality - Detection and enumeration of Pseudomonas aeruginosa - Method by membrane filtration《水质 绿脓杆菌的检测及计数 膜滤法》.pdf
  • BS EN ISO 16276-1-2007 Corrosion protection of steel structures by protective paint systems - Assessment of and acceptance criteria for the adhesion cohesion (fracture strength) of.pdf BS EN ISO 16276-1-2007 Corrosion protection of steel structures by protective paint systems - Assessment of and acceptance criteria for the adhesion cohesion (fracture strength) of.pdf
  • BS EN ISO 16276-2-2007 Corrosion protection of steel structures by protective paint systems - Assessment of and acceptance criteria for the adhesion cohesion (fracture strength) of《.pdf BS EN ISO 16276-2-2007 Corrosion protection of steel structures by protective paint systems - Assessment of and acceptance criteria for the adhesion cohesion (fracture strength) of《.pdf
  • BS EN ISO 16278-2016 Health informatics Categorial structure for terminological systems of human anatomy《保健信息学 人类解剖学体系的术语分类结构》.pdf BS EN ISO 16278-2016 Health informatics Categorial structure for terminological systems of human anatomy《保健信息学 人类解剖学体系的术语分类结构》.pdf
  • 相关搜索
    资源标签

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

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