【计算机类职业资格】计算机二级(C++)上机考试1及答案解析.doc

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

1、计算机二级(C+)上机考试 1 及答案解析(总分:-3.00,做题时间:90 分钟)1.改错题 使用 VC6 打开考生文件夹下的工程 test10_1,此工程包含一个源程序文件 test10_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果为: class Base class D1 class D2 class D3 f in Base 源程序文件 test10_1.cpp 清单如下: #include class Base public: Base()coutn; coutn; cout“结果为:“sum(n)_正确答案:(inline long sum(int n)

2、if(n=1) return 1; else return n*n+sum(n-1); )解析:本题考查的是考生对递归函数掌握的熟练程度。递归的终止条件为 n=1 时,值为 1。 3.综合应用题 使用 VC6 打开考生文件夹下的工程 test8_3,此工程包含一个源程序文件 test8_3.cpp,该文件设计了用于输出乘法九九表的类。请认真阅读已有的代码,按要求完成下列操作,将程序补充完整。 (1)定义类 Table 的私有数据成员 x 和 y,分别用于表示九九表中的两个乘数(x*y),它们都是 int 型的数据。请在注释“/*1*“之后添加适当的语句; (2)完成类 Table 的成员函数

3、print()的定义,该函数以“x*y=z“的格式打印出九九表中的一个乘法算式,请使用格式化输出函数 printf 实现,在注释“/*2*“之后添加适当的语句; (3)完成类 Table9 的成员函数 print()的定义,该函数调用基类Table 的 print()函数,将九九表输出到屏幕,请在注释“/*3*“之后添加适当的语句; (4)补充主函数,在屏幕上输出九九表,以便测试所定义的类的正确性。请在注释“/*4*“之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 源程序文件 test8_3.cpp 清单如下: #include #include class

4、 Table /*1* int z; public: void print(int x,int y,int z); ; void Table:print (int x,int y,int z) /*2* class Table9:public Table public: void print(); ; void Table9:print() /*3* int x,y,z; for (i=1;i_正确答案:((1) int x; int y; (2) printf( “%d*%d=%d “,x,y,z); if(z解析:主要考查考生将具体问题抽象为类,将类的定义补充完整,并进行类定义测试的能力。注意(2)中格式化输出函数 printf 的使用格式,%d 代表输出的为整型。

展开阅读全文
相关资源
猜你喜欢
  • ITU-T G 991 2 SPANISH-2003 Single-pair high-speed digital subscriber line (SHDSL) transceivers《单线对高速数字用户线(SH数字用户线路(DSL))收发器 15号研究组》.pdf ITU-T G 991 2 SPANISH-2003 Single-pair high-speed digital subscriber line (SHDSL) transceivers《单线对高速数字用户线(SH数字用户线路(DSL))收发器 15号研究组》.pdf
  • ITU-T G 991 2-2003 Single-pair high-speed digital subscriber line (SHDSL) transceivers (Study Group 15)《单线对高速数字用户线(SHDSL)收发信机-修正1》.pdf ITU-T G 991 2-2003 Single-pair high-speed digital subscriber line (SHDSL) transceivers (Study Group 15)《单线对高速数字用户线(SHDSL)收发信机-修正1》.pdf
  • ITU-T G 992 1 AMD 1 SPANISH-2003 Asymmetric digital subscriber line (ADSL) transceivers Amendment 1 Revised Annex C new Annex I and new Appendix V《非对称数字用户线(ADSL)收发器 1号修正案 修订版附录C新附录.pdf ITU-T G 992 1 AMD 1 SPANISH-2003 Asymmetric digital subscriber line (ADSL) transceivers Amendment 1 Revised Annex C new Annex I and new Appendix V《非对称数字用户线(ADSL)收发器 1号修正案 修订版附录C新附录.pdf
  • ITU-T G 992 1 AMD 1-2003 Asymmetric digital subscriber line (ADSL) transceivers Amendment 1 Revised Annex C new Annex I and new Appendix V SERIES G TRANSMISSION SYSTEMS AND MEDIA D.pdf ITU-T G 992 1 AMD 1-2003 Asymmetric digital subscriber line (ADSL) transceivers Amendment 1 Revised Annex C new Annex I and new Appendix V SERIES G TRANSMISSION SYSTEMS AND MEDIA D.pdf
  • ITU-T G 992 1 ANX H SPANISH-2000 Asymmetric digital subscriber line (ADSL) transceivers Annex H Specific requirements for a synchronized symmetrical DSL (SSDSL) system operating inITU.pdf ITU-T G 992 1 ANX H SPANISH-2000 Asymmetric digital subscriber line (ADSL) transceivers Annex H Specific requirements for a synchronized symmetrical DSL (SSDSL) system operating inITU.pdf
  • ITU-T G 992 1 ANX H-2000 Asymmetric Digital Subscriber Line (ADSL) Tranceivers Annex H Specific Requirements for a Sychronized Symmetrical DSL (SSDSL) System Operating in the Same 1 A.pdf ITU-T G 992 1 ANX H-2000 Asymmetric Digital Subscriber Line (ADSL) Tranceivers Annex H Specific Requirements for a Sychronized Symmetrical DSL (SSDSL) System Operating in the Same 1 A.pdf
  • ITU-T G 992 1 CORR 1 FRENCH-2001 Asymmetric digital subscriber line (ADSL) transceivers Corrigendum 1《非对称数字用户线(ADSL)收发器 系列G 传输系统和媒体数字系统和网络 数字段和有线数字系统 接入网络》.pdf ITU-T G 992 1 CORR 1 FRENCH-2001 Asymmetric digital subscriber line (ADSL) transceivers Corrigendum 1《非对称数字用户线(ADSL)收发器 系列G 传输系统和媒体数字系统和网络 数字段和有线数字系统 接入网络》.pdf
  • ITU-T G 992 1 CORR 1 SPANISH-2001 Asymmetric digital subscriber line (ADSL) transceivers Corrigendum 1《非对称数字用户线(ADSL)收发器 系列G 传输系统和媒体数字系统和网络 数字段和有线数字系统 接入网络》.pdf ITU-T G 992 1 CORR 1 SPANISH-2001 Asymmetric digital subscriber line (ADSL) transceivers Corrigendum 1《非对称数字用户线(ADSL)收发器 系列G 传输系统和媒体数字系统和网络 数字段和有线数字系统 接入网络》.pdf
  • ITU-T G 992 1 CORR 1-2001 Asymmetric Digital Subscriber Line (ADSL) Transceivers Series G Transmission Systems and Media Digital Systems and Networks Digital Sections and Digital L.pdf ITU-T G 992 1 CORR 1-2001 Asymmetric Digital Subscriber Line (ADSL) Transceivers Series G Transmission Systems and Media Digital Systems and Networks Digital Sections and Digital L.pdf
  • 相关搜索

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

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