【计算机类职业资格】2018年计算机等级考试二级C语言程序题练习10及答案解析.doc

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

1、2018 年计算机等级考试二级 C 语言程序题练习 10 及答案解析(总分:100.00,做题时间:60 分钟)一、程序填空题(总题数:1,分数:30.00)给定程序中,函数的功能是将形参 s 所指 字符串中的所有字母字符顺序前移,其他字符顺序 后移,处理后新字符串的首地址作为函数值返回。例如,s 所指字符串为 asd123fgh543df,处理后 新字符串为 asdfghdf123543。请在程序的下画线处填入正确的内容并把下画 线删除,使程序得出正确的结果。注意:源程序保存在考生文件夹下的 BLANK1. C 中。不得增行或删行,也不得更改程序的结构!给定源程序如下。(分数:30)(1)(

2、分数:10)_(2)(分数:10)_(3)(分数:10)_二、程序改错题(总题数:1,分数:30.00)给定程序 MODI1.C 中函数 fun 的功能是将 s 所指 字符串中最后一次出现的与 t1 所指字符串相同的子 串替换成 t2 所指字符串,所形成的新串放在 w 所指 的数组中。此处要求 t1 和 t2 所指字符串的长度相同。例如,当 s 所指字符串中的内容为 “ahcdabfabc”,t1 所指子串中的内容为“ab”,t2 所 指子串中的内为“99”时,在 w 所指的数组中的 内容应为 “abcdabf99c”。请改正程序中的错误,使它能得出正确的结果。注意:不要改动 main 函数,

3、不得增行或删行, 也不得更改程序的结构!给定源程序如下。(分数:30)(1)(分数:15)_(2)(分数:15)_三、程序设计题(总题数:1,分数:40.00)函数 fun 的功能是将 s 所指字符串中 ASCII 值 为奇数的字符删除,串中剩余字符形成一个新串放 在 t 所指的数组中。例如,若 s 所指字符串中的内容为“ABCDE FGI2345”,其中字符 A 的 ASCII 码值为奇数、字符 1 的ASCII 码值也为奇数,都应当删除,其 他依此类推。最后 t 所指的数组中的内容应是 “BDF24”。注意:部分源程序保存在文件 PROG1.C 中。请勿改动主函数 main 和其他函数中的

4、任何 内容,仅在函数 fun 的花括号中填入编写的若干 语句。给定源程序如下。(分数:40.00)_2018 年计算机等级考试二级 C 语言程序题练习 10 答案解析(总分:100.00,做题时间:60 分钟)一、程序填空题(总题数:1,分数:30.00)给定程序中,函数的功能是将形参 s 所指 字符串中的所有字母字符顺序前移,其他字符顺序 后移,处理后新字符串的首地址作为函数值返回。例如,s 所指字符串为 asd123fgh543df,处理后 新字符串为 asdfghdf123543。请在程序的下画线处填入正确的内容并把下画 线删除,使程序得出正确的结果。注意:源程序保存在考生文件夹下的 B

5、LANK1. C 中。不得增行或删行,也不得更改程序的结构!给定源程序如下。(分数:30)(1)(分数:10)_正确答案:(si )解析:填空 1:将字符串 s 中所有字母元素赋给数组 t。(2)(分数:10)_正确答案:(k)解析:填空 2:字符串中所有非字母元素放到字母元 素后面,所以取值范围是 0?k。(3)(分数:10)_正确答案:(0或 0)解析:填空 3:最后给字符串加入结束标识0。二、程序改错题(总题数:1,分数:30.00)给定程序 MODI1.C 中函数 fun 的功能是将 s 所指 字符串中最后一次出现的与 t1 所指字符串相同的子 串替换成 t2 所指字符串,所形成的新串

6、放在 w 所指 的数组中。此处要求 t1 和 t2 所指字符串的长度相同。例如,当 s 所指字符串中的内容为 “ahcdabfabc”,t1 所指子串中的内容为“ab”,t2 所 指子串中的内为“99”时,在 w 所指的数组中的 内容应为 “abcdabf99c”。请改正程序中的错误,使它能得出正确的结果。注意:不要改动 main 函数,不得增行或删行, 也不得更改程序的结构!给定源程序如下。(分数:30)(1)(分数:15)_正确答案:(while (*w)解析:这里要判断的是值的真假,而不是地址, 所以改为 while (*w)。(2)(分数:15)_正确答案:(if ( *r =*p )

7、解析:C 语言中关键字区分大小写,只需运行程 序,就可以根据提示找到错误。三、程序设计题(总题数:1,分数:40.00)函数 fun 的功能是将 s 所指字符串中 ASCII 值 为奇数的字符删除,串中剩余字符形成一个新串放 在 t 所指的数组中。例如,若 s 所指字符串中的内容为“ABCDE FGI2345”,其中字符 A 的 ASCII 码值为奇数、字符 1 的ASCII 码值也为奇数,都应当删除,其 他依此类推。最后 t 所指的数组中的内容应是 “BDF24”。注意:部分源程序保存在文件 PROG1.C 中。请勿改动主函数 main 和其他函数中的任何 内容,仅在函数 fun 的花括号中填入编写的若干 语句。给定源程序如下。(分数:40.00)_正确答案:()解析:要删除 ASCII 码值为奇数的字符,也就是要保 留 ASCII 码值为偶数的字符,由于最终是要获得剩 余字符形成的新串,所以本题的算法是对原字符串 从头到尾进行扫描,并找出 ASCII 码值为偶数的字 符,然后依次存入数组中。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 14879-4-2008 Organic coating systems and linings for protection of industrial apparatus and plants against corrosion caused by aggressive media - Part 4 Linings on metallic .pdf DIN EN 14879-4-2008 Organic coating systems and linings for protection of industrial apparatus and plants against corrosion caused by aggressive media - Part 4 Linings on metallic .pdf
  • DIN EN 14879-5-2007 Organic coating systems and linings for protection of industrial apparatus and plants against corrosion caused by aggressive media - Part 5 Linings on concrete .pdf DIN EN 14879-5-2007 Organic coating systems and linings for protection of industrial apparatus and plants against corrosion caused by aggressive media - Part 5 Linings on concrete .pdf
  • DIN EN 14879-6-2010 Organic coating systems and linings for protection of industrial apparatus and plants against corrosion caused by aggressive media - Part 6 Combined linings wit.pdf DIN EN 14879-6-2010 Organic coating systems and linings for protection of industrial apparatus and plants against corrosion caused by aggressive media - Part 6 Combined linings wit.pdf
  • DIN EN 1488-2000 Building valves - Expansion groups - Tests and requirements German version EN 1488 2000《建筑物阀门 膨胀类 试验和要求》.pdf DIN EN 1488-2000 Building valves - Expansion groups - Tests and requirements German version EN 1488 2000《建筑物阀门 膨胀类 试验和要求》.pdf
  • DIN EN 14880-2005 Surface active agents - Determination of inorganic sulphate content in anionic surface active agents - Potentiometric lead selective electrode titration method En.pdf DIN EN 14880-2005 Surface active agents - Determination of inorganic sulphate content in anionic surface active agents - Potentiometric lead selective electrode titration method En.pdf
  • DIN EN 14881-2005 Surface active agents - Determination of N-(3-dimethylaminopropyl)-alkylamide content in alkylamidopropylbetaines - Gas chromatographic method English version of .pdf DIN EN 14881-2005 Surface active agents - Determination of N-(3-dimethylaminopropyl)-alkylamide content in alkylamidopropylbetaines - Gas chromatographic method English version of .pdf
  • DIN EN 14882-2005 Rubber or plastic coated fabrics - Determination of the static and dynamic coefficient of friction English version of DIN EN 14882 2005《橡胶或塑料覆层织物 摩擦的静态和动态系数的测定》.pdf DIN EN 14882-2005 Rubber or plastic coated fabrics - Determination of the static and dynamic coefficient of friction English version of DIN EN 14882 2005《橡胶或塑料覆层织物 摩擦的静态和动态系数的测定》.pdf
  • DIN EN 14884-2006 Air quality - Stationary source emissions - Determination of total mercury Automated measuring systems English version of DIN EN 14884 2006-03《空气质量 固定源排放 总汞含量测定 自.pdf DIN EN 14884-2006 Air quality - Stationary source emissions - Determination of total mercury Automated measuring systems English version of DIN EN 14884 2006-03《空气质量 固定源排放 总汞含量测定 自.pdf
  • DIN EN 14885-2015 Chemical disinfectants and antiseptics - Application of European Standards for chemical disinfectants and antiseptics German version EN 14885 2015《化学消毒剂和防腐剂 采用化学消.pdf DIN EN 14885-2015 Chemical disinfectants and antiseptics - Application of European Standards for chemical disinfectants and antiseptics German version EN 14885 2015《化学消毒剂和防腐剂 采用化学消.pdf
  • 相关搜索

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

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