【计算机类职业资格】计算机二级(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 代表输出的为整型。

展开阅读全文
相关资源
猜你喜欢
  • GOST IEC 62053-52-2012 Electricity metering equipment (AC) Particular requirements Part 52 Symbols《交流电测量设备 特殊要求 第52部分 符号》.pdf GOST IEC 62053-52-2012 Electricity metering equipment (AC) Particular requirements Part 52 Symbols《交流电测量设备 特殊要求 第52部分 符号》.pdf
  • GOST IEC 62053-61-2012 Electricity metering equipment (a c ) Particular requirements Part 61 Power consumption and voltage requirements《交流电测量设备 特殊要求 第61部分 功耗和电压要求》.pdf GOST IEC 62053-61-2012 Electricity metering equipment (a c ) Particular requirements Part 61 Power consumption and voltage requirements《交流电测量设备 特殊要求 第61部分 功耗和电压要求》.pdf
  • GOST IEC 62054-11-2014 Electricity metering (a c ) Tariff and load control Part 11 Particular requirements for electronic ripple control receivers《交流电力计量 收费和负载控制 第11部分 电子脉动控制接收器的特殊.pdf GOST IEC 62054-11-2014 Electricity metering (a c ) Tariff and load control Part 11 Particular requirements for electronic ripple control receivers《交流电力计量 收费和负载控制 第11部分 电子脉动控制接收器的特殊.pdf
  • GOST IEC 62058-11-2012 Electricity metering equipment AC Acceptance inspection Part 11 General acceptance inspection methods《交流电测量设备 验收 第11部分 通用验收方法》.pdf GOST IEC 62058-11-2012 Electricity metering equipment AC Acceptance inspection Part 11 General acceptance inspection methods《交流电测量设备 验收 第11部分 通用验收方法》.pdf
  • GOST IEC 62058-21-2012 Electricity metering equipment AC Acceptance inspection Part 21 Particular requirements for electromechanical meters for active energy accuracy classes 0 5 1.pdf GOST IEC 62058-21-2012 Electricity metering equipment AC Acceptance inspection Part 21 Particular requirements for electromechanical meters for active energy accuracy classes 0 5 1.pdf
  • GOST IEC 62115-2014 Electric toys Safety requirements《电动玩具 安全》.pdf GOST IEC 62115-2014 Electric toys Safety requirements《电动玩具 安全》.pdf
  • GOST IEC 62151-2013 Safety of equipment electrically connected to a telecommunication network《连接到通信网络上的电气设备的安全性》.pdf GOST IEC 62151-2013 Safety of equipment electrically connected to a telecommunication network《连接到通信网络上的电气设备的安全性》.pdf
  • GOST IEC 62208-2013 Enclosures for low-voltage switchgear and controlgear assemblies General requirements《低压开关设备和控制设备组件用外壳 通用要求》.pdf GOST IEC 62208-2013 Enclosures for low-voltage switchgear and controlgear assemblies General requirements《低压开关设备和控制设备组件用外壳 通用要求》.pdf
  • GOST IEC 62220-1-2011 Medical electrical equipment Characteristics of digital X-ray imaging devices Part 1 Determination of the detective quantum efficiency《医疗电气设备 数字X射线成像装置的特性 第1部.pdf GOST IEC 62220-1-2011 Medical electrical equipment Characteristics of digital X-ray imaging devices Part 1 Determination of the detective quantum efficiency《医疗电气设备 数字X射线成像装置的特性 第1部.pdf
  • 相关搜索

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

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