【计算机类职业资格】二级C语言机试-246及答案解析.doc

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

1、二级 C 语言机试-246 及答案解析(总分:100.00,做题时间:90 分钟)一、填空题(总题数:1,分数:30.00)请补充函数 proc(),该函数的功能是将字符串 str 中的大写字母都改为对应的小写字母,其他字符不变。例如,若输入“How Are You?”,则输出“how are you?”。注意:部分源程序已给出。请勿改动主函数 main 和其他函数中的任何内容。试题程序:#includestdio.h#includestring.h#includeconio.hchar *proc(char str)int i;for(i=0; stri; i+)if(stri=A)retu

2、rn( (3) );void main()char str81;printf(“/nPlease enter a string: “);gets(str);printf(“/nThe result string is: /n%s“,proc(str);(分数:30.00)填空项 1:_填空项 1:_填空项 1:_二、改错题(总题数:1,分数:30.00)1.下列给定程序中,函数 proc()的功能是逐个比较 str1,str2 两个字符串对应位置中的字符,把 ASCII值大或相等的字符依次存放到 str 数组中,形成一个新的字符串。例如,str1 中的字符串为 fshADfg,str2 中的字

3、符串为 sdAEdi,则 sir 中的字符串应为 sshEdig。请修改程序中的错误,使它能得到正确结果。注意:不要改动 main()函数,不得增行或删行,也不得更改程序的结构。试题程序:#includestdio.h#includestring.hvoid proc(char *p, char *q, char *c)int k=0;while( *P|*q)/*found*if (*p=*q)ck=*q;else ck=*p;if(*p)p+;if(*q)q+;/*found*k+void main()char str110=“fshADfg“, str210=“sdAEdi“, str8

4、0=/0;proc(str1, str2, str);printf(“The string str1: “); puts(str1);printf(“The string str2: “); puts(str2);printf(“The result: “); puts(str);(分数:30.00)填空项 1:_三、编程题(总题数:1,分数:40.00)2.请编写一个函数 proc(),它的功能是:将 str 所指字符串中所有下标为奇数位置的字母转换为大写(若该位置上不是字母,则不转换)。例如,若输入 abcde123, 则应输出 aBcDe123。注意:部分源程序已给出。请勿改动主函数 m

5、ain 和其他函数中的任何内容。试题程序:#includestdlib.h#includeconio.h#includestdio.h#includestring.hvoid proc(char*str)void main()char tt81;system (“CLS“);printf(“/nPlease enter an string within 80 characters: /n“);gets(tt);printf(“/n/nAfter changing, the string / %s“, tt);proc(tt);printf(“/nbecomes/n %s/n“, tt);(分数

6、40.00)_二级 C 语言机试-246 答案解析(总分:100.00,做题时间:90 分钟)一、填空题(总题数:1,分数:30.00)请补充函数 proc(),该函数的功能是将字符串 str 中的大写字母都改为对应的小写字母,其他字符不变。例如,若输入“How Are You?”,则输出“how are you?”。注意:部分源程序已给出。请勿改动主函数 main 和其他函数中的任何内容。试题程序:#includestdio.h#includestring.h#includeconio.hchar *proc(char str)int i;for(i=0; stri; i+)if(stri

7、A)return( (3) );void main()char str81;printf(“/nPlease enter a string: “);gets(str);printf(“/nThe result string is: /n%s“,proc(str);(分数:30.00)填空项 1:_ (正确答案:stri=Z)解析:填空项 1:_ (正确答案:stri+=32)解析:填空项 1:_ (正确答案:str)解析:解析 要将字符串中所有的大写字母改为对应得小写字母,首先应该找出字符串中所有的小写字母。判断一个字符是否是大写字母,只要看其是否在 A 和 Z 之间。因此1处填 stri=

8、Z;每找到一个大写字母,就将其改为小写字母。大写字母与小写字母之间的关系为 ASCII 码值相差 32。因此2处填siri+=32 得到的新的字符串放在 str 中,要将其返回给主函数,因此3处填 str。二、改错题(总题数:1,分数:30.00)1.下列给定程序中,函数 proc()的功能是逐个比较 str1,str2 两个字符串对应位置中的字符,把 ASCII值大或相等的字符依次存放到 str 数组中,形成一个新的字符串。例如,str1 中的字符串为 fshADfg,str2 中的字符串为 sdAEdi,则 sir 中的字符串应为 sshEdig。请修改程序中的错误,使它能得到正确结果。注

9、意:不要改动 main()函数,不得增行或删行,也不得更改程序的结构。试题程序:#includestdio.h#includestring.hvoid proc(char *p, char *q, char *c)int k=0;while( *P|*q)/*found*if (*p=*q)ck=*q;else ck=*p;if(*p)p+;if(*q)q+;/*found*k+void main()char str110=“fshADfg“, str210=“sdAEdi“, str80=/0;proc(str1, str2, str);printf(“The string str1: “)

10、 puts(str1);printf(“The string str2: “); puts(str2);printf(“The result: “); puts(str);(分数:30.00)填空项 1:_ (正确答案:(1)错误:if(*p=*q) 正确:if(*p=*q)(2)错误:k+ 正确:k+;)解析:解析 题目中要求将 ASCII 码值较大的字符放到新的字符串中,因此 if 的条件判断语句if(*p=*q)应改为 if(*P=*q);在 C 语言中,每一条语句的结束是以;来标识的。因此 k+后应该加上分号。三、编程题(总题数:1,分数:40.00)2.请编写一个函数 proc()

11、它的功能是:将 str 所指字符串中所有下标为奇数位置的字母转换为大写(若该位置上不是字母,则不转换)。例如,若输入 abcde123, 则应输出 aBcDe123。注意:部分源程序已给出。请勿改动主函数 main 和其他函数中的任何内容。试题程序:#includestdlib.h#includeconio.h#includestdio.h#includestring.hvoid proc(char*str)void main()char tt81;system (“CLS“);printf(“/nPlease enter an string within 80 characters: /n“);gets(tt);printf(“/n/nAfter changing, the string / %s“, tt);proc(tt);printf(“/nbecomes/n %s/n“, tt);(分数:40.00)_正确答案:(void proc(char*str)int i;for(i=0; stri!=/0; i+)if(i%2=1 /将其转化为大写)解析:解析 要将字符串中为奇数的字母转换为大写,首先应该判断奇数位置上的字符是否为小写字母,若是则将其转换为大写,若不是则不予处理。

展开阅读全文
相关资源
猜你喜欢
  • EN ISO 21187-2005 en Milk Quantitative determination of bacteriological quality Guidance for establishing and verifying a conversion relationship between routine method results and.pdf EN ISO 21187-2005 en Milk Quantitative determination of bacteriological quality Guidance for establishing and verifying a conversion relationship between routine method results and.pdf
  • EN ISO 21227-1-2003 en Paints and varnishes - Evaluation of defects on coated surfaces using optical imaging - Part 1 General guidance《油漆和清漆 用光学成像法评价涂漆表面的缺陷 第1部分 一般指南 ISO 21227-1-2.pdf EN ISO 21227-1-2003 en Paints and varnishes - Evaluation of defects on coated surfaces using optical imaging - Part 1 General guidance《油漆和清漆 用光学成像法评价涂漆表面的缺陷 第1部分 一般指南 ISO 21227-1-2.pdf
  • EN ISO 21227-2-2006 en Paints and varnishes - Evaluation of defects on coated surfaces using optical imaging - Part 2 Evaluation procedure for multiimpact stone-chipping test《色漆和清漆.pdf EN ISO 21227-2-2006 en Paints and varnishes - Evaluation of defects on coated surfaces using optical imaging - Part 2 Evaluation procedure for multiimpact stone-chipping test《色漆和清漆.pdf
  • EN ISO 21227-3-2007 en Paints and varnishes - Evaluation of defects on coated surfaces using optical imaging - Part 3 Evaluation of delamination and corrosion around a scribe《涂料和清漆.pdf EN ISO 21227-3-2007 en Paints and varnishes - Evaluation of defects on coated surfaces using optical imaging - Part 3 Evaluation of delamination and corrosion around a scribe《涂料和清漆.pdf
  • EN ISO 21254-1-2011 en Lasers and laser-related equipment - Test methods for laser-induced damage threshold - Part 1 Definitions and general principles《激光器及激光器相关设备 激光感应损伤阀值的试验方法 第1.pdf EN ISO 21254-1-2011 en Lasers and laser-related equipment - Test methods for laser-induced damage threshold - Part 1 Definitions and general principles《激光器及激光器相关设备 激光感应损伤阀值的试验方法 第1.pdf
  • EN ISO 21254-2-2011 en Lasers and laser-related equipment - Test methods for laser-induced damage threshold - Part 2 Threshold determination《激光器和激光器相关设备 激光感应损伤阈值的试验方法 第2部分 阈值测定(ISO.pdf EN ISO 21254-2-2011 en Lasers and laser-related equipment - Test methods for laser-induced damage threshold - Part 2 Threshold determination《激光器和激光器相关设备 激光感应损伤阈值的试验方法 第2部分 阈值测定(ISO.pdf
  • EN ISO 21254-3-2011 en Lasers and laser-related equipment - Test methods for laser-induced damage threshold - Part 3 Assurance of laser power (energy) handling capabilities《激光器和激光器.pdf EN ISO 21254-3-2011 en Lasers and laser-related equipment - Test methods for laser-induced damage threshold - Part 3 Assurance of laser power (energy) handling capabilities《激光器和激光器.pdf
  • EN ISO 21258-2010 en Stationary source emissions - Determination of the mass concentration of dinitrogen monoxide (N2O) - Reference method Non-dispersive infrared method《固定源排放 氧化亚氨.pdf EN ISO 21258-2010 en Stationary source emissions - Determination of the mass concentration of dinitrogen monoxide (N2O) - Reference method Non-dispersive infrared method《固定源排放 氧化亚氨.pdf
  • EN ISO 21281-2005 en Construction and layout of pedals of self-propelled sit-down rider-controlled industrial trucks - Rules for the construction and layout of pedals《自行式乘坐控制工业货车的踏.pdf EN ISO 21281-2005 en Construction and layout of pedals of self-propelled sit-down rider-controlled industrial trucks - Rules for the construction and layout of pedals《自行式乘坐控制工业货车的踏.pdf
  • 相关搜索

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

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