【计算机类职业资格】国家二级C++机试(操作题)模拟试卷319及答案解析.doc

上传人:twoload295 文档编号:1331817 上传时间:2019-10-17 格式:DOC 页数:3 大小:32KB
下载 相关 举报
【计算机类职业资格】国家二级C++机试(操作题)模拟试卷319及答案解析.doc_第1页
第1页 / 共3页
【计算机类职业资格】国家二级C++机试(操作题)模拟试卷319及答案解析.doc_第2页
第2页 / 共3页
【计算机类职业资格】国家二级C++机试(操作题)模拟试卷319及答案解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级 C+机试(操作题)模拟试卷 319及答案解析(总分:6.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:2.00)1.使用 VC6打开考生文件夹下的源程序文件 modi1cpp,该程序运行时有错,请改正其中的错误,使程序正常运行,即使程序在界面输出以下类似内容: 0012FF68 1 0012FF3C 5 0012FF6C 2 0012FF44 4 0012FF70 3 0012FF4C 3 0023FF74 4 0012FF54 2 0012FF78 5 0012FF5C 1 006AFDCC006AFDEF 数据可能因为机器的不同,程序的输出的内容会有差异。只要相差

2、为 4的连续地址即可。 注意:不要改动 main函数,不能增行或删行,也不能更改程序的结构,错误的语句在*error*的下面。#includeiostreamusing namespace std;int main() int*p,a5=1,2,3,4,5; double*q,b5=50,40,30,20,10; int x; p=a; q=b; *error* for(x=0;x=5;x+) *error* coutp+x “ “ (p+x)“ “q+x“ “(q+x)endl; return 0;(分数:2.00)_二、简单应用题(总题数:1,分数:2.00)2.使用 VC6打开考生文件夹

3、下的源程序文件 modi2cpp。阅读下列函数说明和代码。函数 func(intd,int n)的功能是将长度为 num的数组 d的每一个数字是奇数的扩大 1倍,并存储到数组 d中。 例如:1 2 3 4 5 6 7 8 9 返回:2 2 6 4 10 6 14 8 18 将 func(int d,int num)补充完整。 注意:请勿改动主函数。#includeiostreamhVoid func(int d,int num)int main() int Data=1,2,3,4,5,6,7,8,9); func(Data,9); for(int i=0;isizeof(Data)sizeo

4、f(int);i+) coutDatai ; coutendl; return 0;(分数:2.00)_三、综合应用题(总题数:1,分数:2.00)3.使用 VC6打开考生文件夹下的源程序文件 modi3cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1) 重载运算符 int,请在注释*1*后添加适当的语句。 (2)重载运算符“”,请在注释*2*后添加适当的语句。 (3)在主函数 main()中定义变量 i,并调用对象 obi的 int运算符,给变量赋初值为 10,请在注释*3*后添加适当的语句。 (4)调用 obj的“”运算符输出: HelloTest 注意:增加代

5、码,或者修改代码的伊鼠已经川符号表示出来。请不要修改其他的程序代码。#includeiostreamusing namespace std;Class TestClasspublic: *1* cout“int“endl; return 10; *2* coutstrendl; ;int main() TestClass obj; *3* *4* return 0;(分数:2.00)_国家二级 C+机试(操作题)模拟试卷 319答案解析(总分:6.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:2.00)1.使用 VC6打开考生文件夹下的源程序文件 modi1cpp,该程序运行时

6、有错,请改正其中的错误,使程序正常运行,即使程序在界面输出以下类似内容: 0012FF68 1 0012FF3C 5 0012FF6C 2 0012FF44 4 0012FF70 3 0012FF4C 3 0023FF74 4 0012FF54 2 0012FF78 5 0012FF5C 1 006AFDCC006AFDEF 数据可能因为机器的不同,程序的输出的内容会有差异。只要相差为 4的连续地址即可。 注意:不要改动 main函数,不能增行或删行,也不能更改程序的结构,错误的语句在*error*的下面。#includeiostreamusing namespace std;int main

7、) int*p,a5=1,2,3,4,5; double*q,b5=50,40,30,20,10; int x; p=a; q=b; *error* for(x=0;x=5;x+) *error* coutp+x “ “ (p+x)“ “q+x“ “(q+x)endl; return 0;(分数:2.00)_正确答案:(正确答案:(1)for(x=0;xp+x “ “ *(p+x) “ “ q+x “ “ *(q+x) endl;)解析:解析:(1)根据数组 a、b 定义,它们都是 5个元素,而第 1个标识下的“for(x=0;x=5;x+)”循环了 6次,应该是 5次,所以第 1个标识下的

8、将其修改为“for(x=0;xp+x“ “*(p+x)“ “q+x“ “*(q+x)endl;”。二、简单应用题(总题数:1,分数:2.00)2.使用 VC6打开考生文件夹下的源程序文件 modi2cpp。阅读下列函数说明和代码。函数 func(intd,int n)的功能是将长度为 num的数组 d的每一个数字是奇数的扩大 1倍,并存储到数组 d中。 例如:1 2 3 4 5 6 7 8 9 返回:2 2 6 4 10 6 14 8 18 将 func(int d,int num)补充完整。 注意:请勿改动主函数。#includeiostreamhVoid func(int d,int nu

9、m)int main() int Data=1,2,3,4,5,6,7,8,9); func(Data,9); for(int i=0;isizeof(Data)sizeof(int);i+) coutDatai ; coutendl; return 0;(分数:2.00)_正确答案:(正确答案:for(int i=0;i解析:解析:(1)由审题分析可知,利用循环来逐个判断 d中的元素,d中元素个数为 num,因此循环变量从 0变化至 num。 (2)在循环内,用 if判断该元素是不是奇数,即 if(di2!=0),将满足条件的di扩大一倍。三、综合应用题(总题数:1,分数:2.00)3.使用

10、 VC6打开考生文件夹下的源程序文件 modi3cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1) 重载运算符 int,请在注释*1*后添加适当的语句。 (2)重载运算符“”,请在注释*2*后添加适当的语句。 (3)在主函数 main()中定义变量 i,并调用对象 obi的 int运算符,给变量赋初值为 10,请在注释*3*后添加适当的语句。 (4)调用 obj的“”运算符输出: HelloTest 注意:增加代码,或者修改代码的伊鼠已经川符号表示出来。请不要修改其他的程序代码。#includeiostreamusing namespace std;Class Te

11、stClasspublic: *1* cout“int“endl; return 10; *2* coutstrendl; ;int main() TestClass obj; *3* *4* return 0;(分数:2.00)_正确答案:(正确答案:(1)添加语句:operator int() (2)添加语句:operator“Hello Test“;)解析:解析:(1)题目 1要求“重载运算符 int”的定义。运算符重载的方法是定义一个重载运算符的函数,其一般格式为:函数类型 opemmr运算符名称(形参列表)对运算符的重载处理)。所以第 1个标识下,重载运算符 int的语句为“operator int()”。 (2)题目 2要求“重载运算符”。同(1),第 2个标识下“”的重载函数定义为“operator”运算符输出“HelloTest”“。重载运算符“”后,不仅能输出标准类型数据,而且可以输出用户自己定义的类对象。所以直接添加要输出的字符串即可,即“obj“Hello Test“;”。

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf
  • BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf
  • 相关搜索

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

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