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

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

1、国家二级 C+机试(操作题)模拟试卷 377及答案解析(总分:6.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:2.00)1.使用 VC6打开考生文件夹下的源程序文件 modilcpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: m=一 10 n=一 10 p=0 q=10 z=A 注意:错误的语句在*4*的下面,修改该语句即可。 #include void msin() double m=1 0; float n=1 0; bool P=1; int q=10; char z=a; m=一 m; *error* n=n; *error* p=一P; *err

2、or* q=q; z=z 一 32; coutmnpqz_二、简单应用题(总题数:1,分数:2.00)2.使用 VC6打开考生文件夹下的源程序文件 modi2epp。阅读下列函数说明和代码,补充空出的代码。函数 DecToBin(char*des,int n)的功能是将十进制数据 n转换成二进制数据,并将转换结果存放在 des中。 如:120 的二进制数据为 1111000 例: DecToBin(char*des,1 20); coutdes #define MAXLEN 1 02 4 void DecToBin(char*des,int n) void main() char deSMAX

3、LEN; int n=12 0; DecToBin(des,n); coutdes_三、综合应用题(总题数:1,分数:2.00)3.使用 VC6打开考生文件夹下的源程序文件 modi3cpp。请完成以下部分,实现在屏幕上输出为:1estClass3TestClass2这个程序需要修改的部分,请按照以下部分实现。(1)类 TestClass0不能被实例化,请定义一个纯虚函数 print,在注释*1*后添加适当的语句。(2)类 TestClass1私有虚继承类 TestClass0,请在注释*2*后添加适当的语句。(3)类 TestClass2公有继承类TestClass0,请在注释*3*后添加适

4、当的语句。(4)类 TestClass3公有继承类 TestClass2与 TestClass1,请在注释*4*后添加适当的语句。注意:仅在函数指定位置添加语句,请勿改动主函数 main与其他函数中的任何内容。#includeiostreamhClass TeStClass0 *1*;*2*Class TestCiass1:public: void print() cout“TestClass1”end1; );*3*C1ass TeStClass2:public: void print() cout“TestClass2”end1; ,*4*C1ass TeStClass3:public:

5、void print() cout“TestClass3”end1; ;Void main() TeStClasS3 C3; TestClass2 c2 ; c3print(); c2print(); return;(分数:2.00)_国家二级 C+机试(操作题)模拟试卷 377答案解析(总分:6.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:2.00)1.使用 VC6打开考生文件夹下的源程序文件 modilcpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: m=一 10 n=一 10 p=0 q=10 z=A 注意:错误的语句在*4*的下面,修改该语句即可。

6、 #include void msin() double m=1 0; float n=1 0; bool P=1; int q=10; char z=a; m=一 m; *error* n=n; *error* p=一P; *error* q=q; z=z 一 32; coutmnpqz_正确答案:(正确答案:(1)n=一 n; (2)P=!P; (3)q=一 q;)解析:解析:本题主要考察了考生对算数运算符和逻辑运算符的掌握程度,考察的运算符包括负号运算符“一”和取反运算符“!”等基本运算符。二、简单应用题(总题数:1,分数:2.00)2.使用 VC6打开考生文件夹下的源程序文件 modi

7、2epp。阅读下列函数说明和代码,补充空出的代码。函数 DecToBin(char*des,int n)的功能是将十进制数据 n转换成二进制数据,并将转换结果存放在 des中。 如:120 的二进制数据为 1111000 例: DecToBin(char*des,1 20); coutdes #define MAXLEN 1 02 4 void DecToBin(char*des,int n) void main() char deSMAXLEN; int n=12 0; DecToBin(des,n); coutdes_正确答案:(正确答案:int j,i=0; char temp; whi

8、le(n!=0) desi=n2+0; n=n2; i+; 转化结果为 2进制最高位在 des的下标最低处,顺序刚好反了 deSi=NULL; for(j=0;ji2;j+) 将顺序倒过来 temp=desj;交换 desj=desi 一 1一 j; desi一 1一 j=temp; )解析:解析:函数 DecToBin(char*des,int n)的功能是实现十进制数转换成二进制数,可采用除 2取余的方法来求得。由于要将最终的结果保存在字符数组中,因此在定义的函数中将将相除得到的数字 0和1,再加上字符“0”的 ASC码从而实现将数字转换成 ASC码显示,考虑到除 2取余得到的结果是倒序的

9、因此程序最后通过交换实现结果的正确显示。三、综合应用题(总题数:1,分数:2.00)3.使用 VC6打开考生文件夹下的源程序文件 modi3cpp。请完成以下部分,实现在屏幕上输出为:1estClass3TestClass2这个程序需要修改的部分,请按照以下部分实现。(1)类 TestClass0不能被实例化,请定义一个纯虚函数 print,在注释*1*后添加适当的语句。(2)类 TestClass1私有虚继承类 TestClass0,请在注释*2*后添加适当的语句。(3)类 TestClass2公有继承类TestClass0,请在注释*3*后添加适当的语句。(4)类 TestClass3公

10、有继承类 TestClass2与 TestClass1,请在注释*4*后添加适当的语句。注意:仅在函数指定位置添加语句,请勿改动主函数 main与其他函数中的任何内容。#includeiostreamhClass TeStClass0 *1*;*2*Class TestCiass1:public: void print() cout“TestClass1”end1; );*3*C1ass TeStClass2:public: void print() cout“TestClass2”end1; ,*4*C1ass TeStClass3:public: void print() cout“Tes

11、tClass3”end1; ;Void main() TeStClasS3 C3; TestClass2 c2 ; c3print(); c2print(); return;(分数:2.00)_正确答案:(正确答案:(1)添加语句:virtual void print()=0; (2)将“class TestClassl:”补充完整为:Class TestClassl:vlrtual private TestClass0 (3)将“class TestClass2:”补充完整为: class TestClass2:public TestClass0 (4)将“class TestClass3:”补充完整为: class TestClass3:public TestClass2,public TestClassl)解析:解析:在 VC环境下打开程序,根据题干给出的几条功能要求,对程序中给出注释下的内容逐个补全或修改。本题从题干要求入手,依次处理各个类,完成各个类的定义。

展开阅读全文
相关资源
猜你喜欢
  • DIN 4902-1972 Industrial trucks hand-carriage and trailer movement-wheels symbols terms explanations《工业货车、手推货车和拖车、动轮、符号、术语、说明》.pdf DIN 4902-1972 Industrial trucks hand-carriage and trailer movement-wheels symbols terms explanations《工业货车、手推货车和拖车、动轮、符号、术语、说明》.pdf
  • DIN 49020-1959 Conduit for Electrical Wiring Screwed Steel Conduit Plain Conduit Couplers《电线导管 带螺纹钢制导管、普通导管和管接头》.pdf DIN 49020-1959 Conduit for Electrical Wiring Screwed Steel Conduit Plain Conduit Couplers《电线导管 带螺纹钢制导管、普通导管和管接头》.pdf
  • DIN 49023-1975 Conduits and fittings for electrical installation flexible corrugated conduits of steel《电气设备用导管和接头 柔性波纹钢管》.pdf DIN 49023-1975 Conduits and fittings for electrical installation flexible corrugated conduits of steel《电气设备用导管和接头 柔性波纹钢管》.pdf
  • DIN 49049-1960 Allocation of the lines to the pipe diameters of steel armoured conduits《对钢制铠装管直径的导线分配》.pdf DIN 49049-1960 Allocation of the lines to the pipe diameters of steel armoured conduits《对钢制铠装管直径的导线分配》.pdf
  • DIN 49073 Berichtigung 1-2010 Metal boxes and boxes of insulating material for recessed mounting for accomodation of accessories up to 16 A 250 V and socket-outlets according to DI0.pdf DIN 49073 Berichtigung 1-2010 Metal boxes and boxes of insulating material for recessed mounting for accomodation of accessories up to 16 A 250 V and socket-outlets according to DI0.pdf
  • DIN 49073-2007 de 4510 Metal boxes and boxes of insulating material for recessed mounting for accomodation of accessories up to 16 A 250 V and socket-outlets according to DIN 49445.pdf DIN 49073-2007 de 4510 Metal boxes and boxes of insulating material for recessed mounting for accomodation of accessories up to 16 A 250 V and socket-outlets according to DIN 49445.pdf
  • DIN 49075-1-1989 Cover plates for use with switches socket-outlets and other accessories intended to be mounted into mounting boxes with openings having a diameter of 45 mm and wit.pdf DIN 49075-1-1989 Cover plates for use with switches socket-outlets and other accessories intended to be mounted into mounting boxes with openings having a diameter of 45 mm and wit.pdf
  • DIN 49075-2-1989 de 6641 Cover plates for use with switches socket-outlets and other accessories intended to be mounted into mounting boxes with openings other than of diameter 45 .pdf DIN 49075-2-1989 de 6641 Cover plates for use with switches socket-outlets and other accessories intended to be mounted into mounting boxes with openings other than of diameter 45 .pdf
  • DIN 49076-1989 Openings in front covers of ducting and trunking for use with switches socket-outlets and other accessories to be mounted into mounting boxes main dimensions《与转换开关、插.pdf DIN 49076-1989 Openings in front covers of ducting and trunking for use with switches socket-outlets and other accessories to be mounted into mounting boxes main dimensions《与转换开关、插.pdf
  • 相关搜索

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

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