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

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

1、二级 C 语言-230 及答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.请补充函数 proc(),该函数的功能是将字符串 str 中的大写字母都改为对应的小写字母,其他字符不变。例如,若输入“How Are You?”,则输出“how are you?”。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc()的横线上填入所编写的若干表达式或语句。 试题程序: #includestdio.h #includestring.h #includeconio.h char*proc(char str

2、) int i; for(i=0;stri;i+) if(stri=“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,分数:30.00)2.下列给定程序中,函数 proc()的功能是逐个比较 str1,str2 两个字符串对应位置中的字符,把比ASCII 值大或相等的字符依次存放到 str 数组中,形成一个新的字符串。 例如,

3、str1 中的字符串为 fshADfg,str2 中的字符串为 sdAEdi,则 str 中的字符串应为 sshEdig。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动 main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #includestdio.h #includestring.h void 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

4、str110=“fshADfg“,str210=“sdAEdi“, str80=“/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,分数:40.00)3.请编写一个函数 proc(),它的功能是:将 str 所指字符串中所有下标为奇数位置的字母转换为大写(若该位置上不是字母,则不转换)。 例如,若输入 abcde123,则应输

5、出 aBcDe123。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc()的花括号中填入所编写的若干语句。 试题程序: #includestdlib.h #includeconio.h #includestdio.h #includestring.h void proc(char*str) void main() char tt81; system(“CLS“); printf(“/nPlease enter an string within80 characters:/n“); gets(tt); printf(“/n/nAfter chan

6、ging,the string /n%s“,tt); proc(tt); printf(“/nbecomes/n%s/n“,tt); (分数:40.00)_二级 C 语言-230 答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.请补充函数 proc(),该函数的功能是将字符串 str 中的大写字母都改为对应的小写字母,其他字符不变。例如,若输入“How Are You?”,则输出“how are you?”。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc()的横线上填入所编写的若干表达式或

7、语句。 试题程序: #includestdio.h #includestring.h #includeconio.h char*proc(char str) int i; for(i=0;stri;i+) if(stri=“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)解析:stri=“Z“ stri+=32 str解析 要将字符串中所有的大写字母改为

8、对应的小写字母,首先应该找出字符串中所有的小写字母。判断一个字符是否是大写字母,只要看其是否在 A 和 Z 之间,因此第一处填“stri=“Z“”;每找到一个大写字母,就将其改为小写字母。大写字母与小写字母之间的关系为ASCII 相差 32,因此第二处填“stri+=32”;得到的新的字符串放在 s1 中,要将其返回给主函数,因此第三处填“str”。二、程序改错题(总题数:1,分数:30.00)2.下列给定程序中,函数 proc()的功能是逐个比较 str1,str2 两个字符串对应位置中的字符,把比ASCII 值大或相等的字符依次存放到 str 数组中,形成一个新的字符串。 例如,str1

9、中的字符串为 fshADfg,str2 中的字符串为 sdAEdi,则 str 中的字符串应为 sshEdig。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动 main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #includestdio.h #includestring.h void 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 str11

10、0=“fshADfg“,str210=“sdAEdi“, str80=“/0“; proc(str1,str2,str); printf(“The string str1:“);puts(str1); printf(“The string str2:“);puts(str2); printf(“The result:“);puts(str); (分数:30.00)解析:错误: if(*p=*q) 正确: if(*p=*q) 错误:k+ 正确:k+; 解析 题目中要求将 ASCII 码值较大的字符放到新的字符串中,因此 if 的条件判断语句“if(*p=*q)”应改为“if(*p=*q)”;在

11、C 语言中,每一条语句的结束是以“;”来标识的,因此k+后应该加上分号。三、程序设计题(总题数:1,分数:40.00)3.请编写一个函数 proc(),它的功能是:将 str 所指字符串中所有下标为奇数位置的字母转换为大写(若该位置上不是字母,则不转换)。 例如,若输入 abcde123,则应输出 aBcDe123。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc()的花括号中填入所编写的若干语句。 试题程序: #includestdlib.h #includeconio.h #includestdio.h #includestring.h v

12、oid proc(char*str) void main() char tt81; system(“CLS“); printf(“/nPlease enter an string within80 characters:/n“); gets(tt); printf(“/n/nAfter changing,the string /n%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/将其转化为大写 解析 要将字符串中为奇数的字母转换为大写,首先应该判断奇数位置上的字符是否为小写字母,若是则将其转换为大写,若不是则不予处理。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN ISO 10545-13-2017 Ceramic tiles - Part 13 Determination of chemical resistance (ISO 10545-13 2016) German version EN ISO 10545-13 2016《瓷砖 第13部分 耐化学腐蚀性的测定(ISO 10545-13-2016) .pdf DIN EN ISO 10545-13-2017 Ceramic tiles - Part 13 Determination of chemical resistance (ISO 10545-13 2016) German version EN ISO 10545-13 2016《瓷砖 第13部分 耐化学腐蚀性的测定(ISO 10545-13-2016) .pdf
  • DIN EN ISO 10545-14-2016 Ceramic tiles - Part 14 Determination of resistance to stains (ISO 10545-14 2015) German version EN ISO 10545-14 2015《瓷砖 第14部分 耐污染性的测定(ISO 10545-14-2015) 德.pdf DIN EN ISO 10545-14-2016 Ceramic tiles - Part 14 Determination of resistance to stains (ISO 10545-14 2015) German version EN ISO 10545-14 2015《瓷砖 第14部分 耐污染性的测定(ISO 10545-14-2015) 德.pdf
  • DIN EN ISO 10545-15-1997 Ceramic tiles - Part 15 Determination of lead and cadmium given off by glazed tiles (ISO 10545-15 1995) German version EN ISO 10545-15 1997《瓷砖 第15部分 釉面砖镉含量.pdf DIN EN ISO 10545-15-1997 Ceramic tiles - Part 15 Determination of lead and cadmium given off by glazed tiles (ISO 10545-15 1995) German version EN ISO 10545-15 1997《瓷砖 第15部分 釉面砖镉含量.pdf
  • DIN EN ISO 10545-16-2012 Ceramic tiles - Part 16 Determination of small colour differences (ISO 10545-16 2010) German version EN ISO 10545-16 2012《瓷砖 第16部分 细小色差测定》.pdf DIN EN ISO 10545-16-2012 Ceramic tiles - Part 16 Determination of small colour differences (ISO 10545-16 2010) German version EN ISO 10545-16 2012《瓷砖 第16部分 细小色差测定》.pdf
  • DIN EN ISO 10545-2-1997 Ceramic tiles - Part 2 Determination of dimensions and surface quality (ISO 10545-2 1995 including Technical Corrigendum 1 1997) German version EN ISO 10545.pdf DIN EN ISO 10545-2-1997 Ceramic tiles - Part 2 Determination of dimensions and surface quality (ISO 10545-2 1995 including Technical Corrigendum 1 1997) German version EN ISO 10545.pdf
  • DIN EN ISO 10545-4-2014 Ceramic tiles - Part 4 Determination of modulus of rupture and breaking strength (ISO 10545-4 2014) German version EN ISO 10545-4 2014《瓷砖 第4部分 断裂模数和破坏强度的测定(.pdf DIN EN ISO 10545-4-2014 Ceramic tiles - Part 4 Determination of modulus of rupture and breaking strength (ISO 10545-4 2014) German version EN ISO 10545-4 2014《瓷砖 第4部分 断裂模数和破坏强度的测定(.pdf
  • DIN EN ISO 10545-5-1997 Ceramic tiles - Part 5 Determination of impact resistance by measurement of coefficient of restitution (ISO 10545-5 1996 including Technical Corrigendum 1 1.pdf DIN EN ISO 10545-5-1997 Ceramic tiles - Part 5 Determination of impact resistance by measurement of coefficient of restitution (ISO 10545-5 1996 including Technical Corrigendum 1 1.pdf
  • DIN EN ISO 10545-6-2012 Ceramic tiles - Part 6 Determination of resistance to deep abrasion for unglazed tiles (ISO 10545-6 2010) German version EN ISO 10545-6 2012《瓷砖 第11部分 无釉砖耐磨深.pdf DIN EN ISO 10545-6-2012 Ceramic tiles - Part 6 Determination of resistance to deep abrasion for unglazed tiles (ISO 10545-6 2010) German version EN ISO 10545-6 2012《瓷砖 第11部分 无釉砖耐磨深.pdf
  • DIN EN ISO 10545-7-1999 Ceramic tiles - Part 7 Determination of resistance to surface abrasion for glazed tiles (ISO 10545-7 1996) German version EN ISO 10545-7 1999《瓷砖 第7部分 上釉瓷砖表面.pdf DIN EN ISO 10545-7-1999 Ceramic tiles - Part 7 Determination of resistance to surface abrasion for glazed tiles (ISO 10545-7 1996) German version EN ISO 10545-7 1999《瓷砖 第7部分 上釉瓷砖表面.pdf
  • 相关搜索

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

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