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

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

1、国家二级 C+机试(操作题)模拟试卷 370及答案解析(总分:6.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:2.00)1.使用 VC6打开考生文件夹下的源程序文件 modi lcpp,该程序运行时有错,请改正错误,使得程序正确执行,并且输出以下语句: TestClass1:0 TestClass2 注意:不要改动 main函数,不能增行或删行,也不能更改程序的结构,错误的语句在 *error*的下面。 #include struct TestClass1 TestClass1(int i=0) m i=i; void print() cout“TestClassl:”“Te

2、stClass2”_二、简单应用题(总题数:1,分数:2.00)2.使用 VC6打开考生文件夹下的源程序文件 modi2cpp。完成 fun()函数,其功能是:将两个从小到大有序数组 a和 b,复制合并出一个有序整数序列 c,其中形参 n和 m分别是数组 a和 b的元素个数。 注意:不能修改程序的其他部分,只能修改 fun()函数。 include void fun (int a,int n,int b,int m,int*c) void main() int A=3,5,7,9,11,1 8,21); int B=6,1 5,1 9,2 1,3 9); int C25,i ; for(i=0

3、iAiBiCi_三、综合应用题(总题数:1,分数:2.00)3.使用 VC6打开考生文件夹下的源程序文件 modi3cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)完成类 Rect的构造函数,实现对变量left、right、top、bottom 的初始化,缺省值都为 0,请在注释*1*后添加适当的语句。(2)完成类 Rectangle的构造函数,请在注释*2*后添加适当的语句。 (3)完成计算矩形对角线长度函数 Diagonal(),请在注释*3*后添加适当的语句。 (4)完成计算周长函数 Girth(),请在注释*4*后添加适当的语句。 程序输出

4、 50 140 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。 #include #include class Rectangle public: int left,right t top , bottom; *1* left=i; right=r; top=t; bottom=b; *2* left=rcleft; right=rcright; top=rctop; bottom=rcbottom; float Diagonal() *3* return int Girth() *4* return ; int main() Rectangle rect(

5、20,50,40,80); Rectangle rect2(rect); coutrect2Diagonal()rect2Girth()_国家二级 C+机试(操作题)模拟试卷 370答案解析(总分:6.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:2.00)1.使用 VC6打开考生文件夹下的源程序文件 modi lcpp,该程序运行时有错,请改正错误,使得程序正确执行,并且输出以下语句: TestClass1:0 TestClass2 注意:不要改动 main函数,不能增行或删行,也不能更改程序的结构,错误的语句在 *error*的下面。 #include struct Tes

6、tClass1 TestClass1(int i=0) m i=i; void print() cout“TestClassl:”“TestClass2”_正确答案:(正确答案:(1)public: (2)TeStClass1 obj 1(0);或 TestClass1 obj1; (3)TestClass2 obj2;)解析:解析:程序要求输出 TestClass1:0 和 TestClass2。从已定源程序的 main主函数开始入手,可以看出程序首先定义 TestClass1和 TestClass2类型的变量,然后通过调用其中的 print成员函数实现输出结果。二、简单应用题(总题数:1,

7、分数:2.00)2.使用 VC6打开考生文件夹下的源程序文件 modi2cpp。完成 fun()函数,其功能是:将两个从小到大有序数组 a和 b,复制合并出一个有序整数序列 c,其中形参 n和 m分别是数组 a和 b的元素个数。 注意:不能修改程序的其他部分,只能修改 fun()函数。 include void fun (int a,int n,int b,int m,int*c) void main() int A=3,5,7,9,11,1 8,21); int B=6,1 5,1 9,2 1,3 9); int C25,i ; for(i=0;iAiBiCi_正确答案:(正确答案:Int

8、i,j; for(i=j=0; in top=t; bottom=b; *2* left=rcleft; right=rcright; top=rctop; bottom=rcbottom; float Diagonal() *3* return int Girth() *4* return ; int main() Rectangle rect(20,50,40,80); Rectangle rect2(rect); coutrect2Diagonal()rect2Girth()_正确答案:(正确答案:(1)添加语句:Rectangle(int 1,int r,int t,int b) (2)添加语句:Rectangle(Rectangle&rc) (3)将“return”补充完整为:return sqrt(rightleft)*(rightleft) + (bottomtop)*(bottomtop); (4)将“return”补充完整为:return 2*(rightleft)+(bottomtop);)解析:解析:类 Rectangle是描述了一个矩形,私有成员分别描述矩形的坐标值,构造函数给私有数据成员赋初值。Rectangle 类的 Diagonal()和 Girth()分别计算矩形的对角线长度和周长,可通过矩形的长和宽计算得到。

展开阅读全文
相关资源
猜你喜欢
  • NBN-EN 26360-1-1992 9375 Dentistry Dental rotary instruments Number coding system Part 1 General characteristics (ISO 6360-1 1985)《齿艺 齿科的旋转仪器 数字系统化 第1部分:总体特性(ISO 6360:1:1985)(修正案)》.pdf NBN-EN 26360-1-1992 9375 Dentistry Dental rotary instruments Number coding system Part 1 General characteristics (ISO 6360-1 1985)《齿艺 齿科的旋转仪器 数字系统化 第1部分:总体特性(ISO 6360:1:1985)(修正案)》.pdf
  • NBN-EN 26373-1992 1250 Data processing Programming languages Minimal BASIC (ISO 6376 1984)《信息处理 编程语言 最低BASIC(ISO 6373:1984)》.pdf NBN-EN 26373-1992 1250 Data processing Programming languages Minimal BASIC (ISO 6376 1984)《信息处理 编程语言 最低BASIC(ISO 6373:1984)》.pdf
  • NBN-EN 264-1993 0000 Safety shut-off devices for combustion plants using liquid fuels Safety requirements and testing《用液体燃料的燃烧设备的安全闭锁装置 安全技术要求和检验》.pdf NBN-EN 264-1993 0000 Safety shut-off devices for combustion plants using liquid fuels Safety requirements and testing《用液体燃料的燃烧设备的安全闭锁装置 安全技术要求和检验》.pdf
  • NBN-EN 2641-1993 6875 Aerospace series Control cable assemblies Combinations and dimensions《航空航天系列 配备齐全的控制电缆 尺寸和组合》.pdf NBN-EN 2641-1993 6875 Aerospace series Control cable assemblies Combinations and dimensions《航空航天系列 配备齐全的控制电缆 尺寸和组合》.pdf
  • NBN-EN 26461-1-1993 1250 Water quality Detection and enumeration of the spores of sulfite-reducing anaerobes (clostridia) Part 1 Method by enrichment in a liquid medium (ISO 6461-1.pdf NBN-EN 26461-1-1993 1250 Water quality Detection and enumeration of the spores of sulfite-reducing anaerobes (clostridia) Part 1 Method by enrichment in a liquid medium (ISO 6461-1.pdf
  • NBN-EN 26461-2-1993 4375 Water quality Detection and enumeration of the spores of sulfite-reducing anaerobes (clostridia) Part 2 Method by membrane filtration (ISO 6461-2 1986)《水质 .pdf NBN-EN 26461-2-1993 4375 Water quality Detection and enumeration of the spores of sulfite-reducing anaerobes (clostridia) Part 2 Method by membrane filtration (ISO 6461-2 1986)《水质 .pdf
  • NBN-EN 26501-1992 3125 《镍铁 送货说明和条件(ISO 6501:1988)》.pdf NBN-EN 26501-1992 3125 《镍铁 送货说明和条件(ISO 6501:1988)》.pdf
  • NBN-EN 26520-1992 5625 《金属熔化焊接法中的缺陷分类,伴有解释性说明(ISO 6520:1982)》.pdf NBN-EN 26520-1992 5625 《金属熔化焊接法中的缺陷分类,伴有解释性说明(ISO 6520:1982)》.pdf
  • NBN-EN 26590-1-1993 5625 Packaging Sacks Vocabulary and types Part 1 Paper sacks (ISO 6590-1 1983)《包装,包囊 词汇和类型 第1部分:纸包(ISO 6590:1:1983)》.pdf NBN-EN 26590-1-1993 5625 Packaging Sacks Vocabulary and types Part 1 Paper sacks (ISO 6590-1 1983)《包装,包囊 词汇和类型 第1部分:纸包(ISO 6590:1:1983)》.pdf
  • 相关搜索

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

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