【计算机类职业资格】全国计算机等级考试二级C++上机题库试卷十2013年及答案解析.doc

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

1、全国计算机等级考试二级 C+上机题库试卷十 2013 年及答案解析(总分:3.00,做题时间:90 分钟)1.改错题 使用 VC6 打开考生文件夹下的工程 kt15_1,此工程包含一个源程序文件 kt15_1.cpp,但该程序运行有问题,请改正程序中的错误,使该程序的输出结果为: Previous=9,Next=11 源程序文件kt15_1.cpp 清单如下: #include /*found*/ intmain() intx=10,y,z; prevnext(x,y,z); coutxn; coutxn; coutfun(x,n)_正确答案:(if(x=0) return 0; if(n=0

2、) return 1; int y=1; for(int i=0;i解析:本题主要考查用基本控制结构与函数知识解决实际问题的能力。求 x 的 n 次幂是数学中常用的运算,编程时在 x=0 与 n=0 时需特殊处理。3.综合应用题 使用 VC6 打开考生文件夹下的工程 kt15_3。此工程包含一个 kt15_3.cpp,其中定义了 类A、A1 和 A2,其中 A1 类由 A 类公有派生,A2 类由 A1 类公有派生。上述三个类的定义并不完整,请按要求完成下列操作,将程序补充完整。 (1)定义类 A 的构造函数,该构造函数有一个整型的参数 x,在构造函数中请将 x 赋值给数据成员 a。请在注释“/

3、1*”之后添加适当的语句。 (2)定义类 A1 的构造函数,该构造函数有两个整型参数 x 和 y,在构造函数中请将 x 赋值给数据成员 b,将 y 作为基类 A 构造函数的参数值传入。请在注释“/*2*”后添加适当的语句。 (3)定义类 A2 的构造函数,该构造函数有三个整型的参数 x,y 和 z,在构造函数中请将 x 赋值给数据成员 c,将 y 和 z 分别赋值给基类 A1 构造函数的参数 x 和 y。请在注释“/*3*”之后添加适当的语句。 (4)完成类 A2 的成员函数 show 的定义,该函数调用基类成员函数,输出基类数据成员 a 和 b 及类 A2 自身的数据成员 c 的值,上述三

4、个值在输出时以空格隔开。请在注释“/*4*”之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 程序输出结果如下: 9 6 962 源程序文件 kt15_3.cpp 清单如下: #include classA inta; public: /*1* intgeta()returna; ; classA1:publicA intb; public: /*2* intgetb()returnb; ; classA2:publicA1 intc; public: /*3* voidshow() /*4* ; voidmain() A2a(2,6,9); couta.geta()a.getb()_正确答案:((1)A(int x) a=x; (2)A1(int x,int y) : A(y)b=x; (3)A2(int x,int y,int z):A1(y,z)c=x; (4)coutgeta()“ “getb()“ “; coutc“/n“;)解析:本题主要考查对继承和派生的掌握程度,涉及派生类构造函数的定义、基类成员函数的访问等内容。派生类的构造函数的格式请牢记,另外派生类构造函数及析构函数的执行顺序也是需要掌握的。

展开阅读全文
相关资源
猜你喜欢
  • ITU-T Q 1902 5 SPANISH-2001 Bearer Independent Call Control protocol (Capability Set 2) Exceptions to the application transport mechanism in the context of BICC《与承载无关呼叫控制协议(能力集2) 在.pdf ITU-T Q 1902 5 SPANISH-2001 Bearer Independent Call Control protocol (Capability Set 2) Exceptions to the application transport mechanism in the context of BICC《与承载无关呼叫控制协议(能力集2) 在.pdf
  • ITU-T Q 1902 5-2001 Bearer Independent Call Control Protocol (Capability Set 2) Exceptions to the Application Transport Mechanism in the Context of BICC Series Q Switching and Signo .pdf ITU-T Q 1902 5-2001 Bearer Independent Call Control Protocol (Capability Set 2) Exceptions to the Application Transport Mechanism in the Context of BICC Series Q Switching and Signo .pdf
  • ITU-T Q 1902 6 AMD 1 SPANISH-2004 Bearer Independent Call Control protocol (Capability Set 2) Generic signalling procedures for the support of the ISDN User Part supplementary serv承.pdf ITU-T Q 1902 6 AMD 1 SPANISH-2004 Bearer Independent Call Control protocol (Capability Set 2) Generic signalling procedures for the support of the ISDN User Part supplementary serv承.pdf
  • ITU-T Q 1902 6 AMD 1-2004 Bearer Independent Call Control protocol (Capability Set 2) Generic signalling procedures for the support of the ISDN User Part supplementary services andSW.pdf ITU-T Q 1902 6 AMD 1-2004 Bearer Independent Call Control protocol (Capability Set 2) Generic signalling procedures for the support of the ISDN User Part supplementary services andSW.pdf
  • ITU-T Q 1902 6 FRENCH-2001 Bearer Independent Call Control protocol (Capability Set 2) Generic signalling procedures for the support of the ISDN user part supplementary services an.pdf ITU-T Q 1902 6 FRENCH-2001 Bearer Independent Call Control protocol (Capability Set 2) Generic signalling procedures for the support of the ISDN user part supplementary services an.pdf
  • ITU-T Q 1902 6 SPANISH-2001 Bearer Independent Call Control protocol (Capability Set 2) Generic signalling procedures for the support of the ISDN user part supplementary services a.pdf ITU-T Q 1902 6 SPANISH-2001 Bearer Independent Call Control protocol (Capability Set 2) Generic signalling procedures for the support of the ISDN user part supplementary services a.pdf
  • ITU-T Q 1902 6-2001 Bearer Independent Call Control Protocol (Capability Set 2) Generic Signalling Procedures for the Support of the ISDN User Part Supplementary Services and for Bal.pdf ITU-T Q 1902 6-2001 Bearer Independent Call Control Protocol (Capability Set 2) Generic Signalling Procedures for the Support of the ISDN User Part Supplementary Services and for Bal.pdf
  • ITU-T Q 1912 1 FRENCH-2001 Interworking between Signalling System No 7 ISDN user part and the Bearer Independent Call Control protocol《7号信令系统综合业务数字网用户部分和与承载无关呼叫控制协议的交互工作 Q系列 交换和信令 .pdf ITU-T Q 1912 1 FRENCH-2001 Interworking between Signalling System No 7 ISDN user part and the Bearer Independent Call Control protocol《7号信令系统综合业务数字网用户部分和与承载无关呼叫控制协议的交互工作 Q系列 交换和信令 .pdf
  • ITU-T Q 1912 1 SPANISH-2001 Interworking between Signalling System No 7 ISDN user part and the Bearer Independent Call Control protocol《7号信令系统综合业务数字网用户部分和与承载无关呼叫控制协议的交互工作 Q系列 交换和信令.pdf ITU-T Q 1912 1 SPANISH-2001 Interworking between Signalling System No 7 ISDN user part and the Bearer Independent Call Control protocol《7号信令系统综合业务数字网用户部分和与承载无关呼叫控制协议的交互工作 Q系列 交换和信令.pdf
  • 相关搜索

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

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