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

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

1、国家二级 C+机试(操作题)模拟试卷 363 及答案解析(总分:6.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:2.00)1.使用 VC6 打开考生文件夹下的源程序文件 modilcpp,该程序运行时有错,请改正其中的错误,使程序正确运行,并且使程序输出的结果为: 30 130 注意:错误的语句在 *error*的下面,修改该语句即可。 #include int a=10; class CObj public: CObj() a=b=0; void di splay() *error* coutab_二、简单应用题(总题数:1,分数:2.00)2.使用 VC6 打开考生文件夹

2、下的源程序文件 modi2cpp。阅读下列函数说明和代码,完成空出部分的程序。实现函数 sort(intA,int n),用冒泡法将数组排序。 提示:所谓冒泡法,就是每次把相邻的两个数交换,较大的数交换到后面。这样下标从 0 到 n-1 的数与其后面相邻的数交换,可以把最大的数交换到数组的末端。进行 n 次下标从 0 到 n-1 的交换,则数组则会变成有序的,而且是由大到小的顺序。 注意:不能修改程序的其他部分,并且不能删除其他的部分,也不能修改程序的结构。#includeiostreamh#define N 10void sort(int AN,int n)int main() int AN

3、5,7,4,6,i0,13,78,一 4,9,2 0); Sort(A,10); for(int i=0;isizeof(A)Sizeof(int),i+) coutAi; coutend1; return 0;(分数:2.00)_三、综合应用题(总题数:1,分数:2.00)3.使用 VC6 打开考生文件夹下的源程序文件 modi3cpp,其中定义了用于表示日期的类 Date,但类 Date的定义并不完整。请按要求完成下列操作,将类 Date 的定义补充完成。 (1)定义私有数据成员year、month 和 day,分别用于表示年、月和日,它们都是 int 型的数据。请在注释*1*之后添加适

4、当的语句。 (2)完成默认构造函数 Date 的定义,使 Date 对象的默认值为:year=1,month=1,day=1,请在注释*2*之后添加适当的语句。 (3)完成重载构造函数Date(int y,int m,int d)的定义,把数据成员 year、month 和 day 分别初始化为参数 y、m 和 d 的值,请在注释*3*之后添加适当的语句。 (4)完成成员函数 print()的类外定义,使其以“年一月一日”的格式将 Date 对象的值输出到屏幕上,例如:2008-8-8。请在注释*4*之后添加适当的语句。 注意:仅在函数指定位置添加语句,请勿改动主函数 main 与其他函数中的

5、任何内容。 #include class Date public: *2* Date(int y,int m,int d) *3* void print()const; private: data member *1* ; void Date:print()const *4* int main() Date national_day(1949,i0,1); national_dayprint(); return 0; (分数:2.00)_国家二级 C+机试(操作题)模拟试卷 363 答案解析(总分:6.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:2.00)1.使用 VC6 打

6、开考生文件夹下的源程序文件 modilcpp,该程序运行时有错,请改正其中的错误,使程序正确运行,并且使程序输出的结果为: 30 130 注意:错误的语句在 *error*的下面,修改该语句即可。 #include int a=10; class CObj public: CObj() a=b=0; void di splay() *error* coutab_正确答案:(正确答案:(1)coutaba+=a; (3)a+=:a;)解析:解析:程序当中定义了全局变量 a 和类 CObj,类 CObj 含有成员变量 a 和 b,类 CObj 的变量 a 和全局变量 a 均为整型变量,名字完全一样

7、使用时需要注意区分。类 CObj 成员函数 display()打印变量 a和 b 的值,func(int a)函数和 func20 均使类成员变量 a 增加,但是增加方式不同。二、简单应用题(总题数:1,分数:2.00)2.使用 VC6 打开考生文件夹下的源程序文件 modi2cpp。阅读下列函数说明和代码,完成空出部分的程序。实现函数 sort(intA,int n),用冒泡法将数组排序。 提示:所谓冒泡法,就是每次把相邻的两个数交换,较大的数交换到后面。这样下标从 0 到 n-1 的数与其后面相邻的数交换,可以把最大的数交换到数组的末端。进行 n 次下标从 0 到 n-1 的交换,则数组

8、则会变成有序的,而且是由大到小的顺序。 注意:不能修改程序的其他部分,并且不能删除其他的部分,也不能修改程序的结构。#includeiostreamh#define N 10void sort(int AN,int n)int main() int AN=5,7,4,6,i0,13,78,一 4,9,2 0); Sort(A,10); for(int i=0;isizeof(A)Sizeof(int),i+) coutAi; coutend1; return 0;(分数:2.00)_正确答案:(正确答案:int i t j,k,t; for(i=0;in 一 1;i+) for(k=i,J=i

9、1;Jn;J+) if(AkAj)如果前面的 比后面的小则需要交换 k=j; if(k!=i) 交换 t=Ai; Ai=Ak; Ak=t; )解析:解析:函数 sort(int A,int n)用冒泡排序法把数组进行从大到小的排序,冒泡法排序利用了求数组中最小值及其位置的算法,首先从 n 个数中找出最大值,放在第一个元素位置上,再从剩下的 n-1个数中找出最大值,放在第二个元素位置上,这样不断重复下去,直到剩下最后一个数。三、综合应用题(总题数:1,分数:2.00)3.使用 VC6 打开考生文件夹下的源程序文件 modi3cpp,其中定义了用于表示日期的类 Date,但类 Date的定义并不

10、完整。请按要求完成下列操作,将类 Date 的定义补充完成。 (1)定义私有数据成员year、month 和 day,分别用于表示年、月和日,它们都是 int 型的数据。请在注释*1*之后添加适当的语句。 (2)完成默认构造函数 Date 的定义,使 Date 对象的默认值为:year=1,month=1,day=1,请在注释*2*之后添加适当的语句。 (3)完成重载构造函数Date(int y,int m,int d)的定义,把数据成员 year、month 和 day 分别初始化为参数 y、m 和 d 的值,请在注释*3*之后添加适当的语句。 (4)完成成员函数 print()的类外定义,

11、使其以“年一月一日”的格式将 Date 对象的值输出到屏幕上,例如:2008-8-8。请在注释*4*之后添加适当的语句。 注意:仅在函数指定位置添加语句,请勿改动主函数 main 与其他函数中的任何内容。 #include class Date public: *2* Date(int y,int m,int d) *3* void print()const; private: data member *1* ; void Date:print()const *4* int main() Date national_day(1949,i0,1); national_dayprint(); return 0; (分数:2.00)_正确答案:(正确答案:(1)添加语句:int year,month,day; (2)添加语句: Date()(year=1;month=1;day=1; (3)添加语句:year=y;month=m;day=d; (4)添加语句:coutyear“一”month“一”dayendl;)解析:解析:在 VC 环境下打开程序,根据题干给出的几条功能要求,对程序中给出注释下的内容逐个补全或修改。从已给定源程序的 main 主函数开始入 l 手,可以看出程序通过调用类 Date 和函数 print 实现各种输出操作。

展开阅读全文
相关资源
猜你喜欢
  • BS EN 61086-1-2004 Coatings for loaded printed wire boards (conformal coatings) - Definitions classification and general requirements《承载印制电路板用涂料(敷形涂料) 定义、分类及一般要求》.pdf BS EN 61086-1-2004 Coatings for loaded printed wire boards (conformal coatings) - Definitions classification and general requirements《承载印制电路板用涂料(敷形涂料) 定义、分类及一般要求》.pdf
  • BS EN 61086-2-2004 Coatings for loaded printed wire boards (conformal coatings) - Methods of test《承载印制电路板用涂料(敷形涂料) 试验方法》.pdf BS EN 61086-2-2004 Coatings for loaded printed wire boards (conformal coatings) - Methods of test《承载印制电路板用涂料(敷形涂料) 试验方法》.pdf
  • BS EN 61086-3-1-2004 Coatings for loaded printed wire boards (conformal coatings) - Specifications for individual materials - Coatings for general purpose (class 1) high reliabilit.pdf BS EN 61086-3-1-2004 Coatings for loaded printed wire boards (conformal coatings) - Specifications for individual materials - Coatings for general purpose (class 1) high reliabilit.pdf
  • BS EN 61094-1-2001 Specification for measurement microphones - Specifications for laboratory standard microphones《传声器测量规范 实验室标准传声器规范》.pdf BS EN 61094-1-2001 Specification for measurement microphones - Specifications for laboratory standard microphones《传声器测量规范 实验室标准传声器规范》.pdf
  • BS EN 61094-2-2009 Electroacoustics — nMeasurement microphones — nPart 2 Primary method for pressure calibration of nlaboratory standard microphones by the reciprocity ntechnique《电.pdf BS EN 61094-2-2009 Electroacoustics — nMeasurement microphones — nPart 2 Primary method for pressure calibration of nlaboratory standard microphones by the reciprocity ntechnique《电.pdf
  • BS EN 61094-3-2016 Electroacoustics Measurement microphones Primary method for free-field calibration of laboratory standard microphones by the reciprocity technique《电声学 测量传声器 用互易技.pdf BS EN 61094-3-2016 Electroacoustics Measurement microphones Primary method for free-field calibration of laboratory standard microphones by the reciprocity technique《电声学 测量传声器 用互易技.pdf
  • BS EN 61094-4-1996 Specification for measurement microphones - Specifications for working standard microphones《测量规范 第4部分 工作标准传声器规范》.pdf BS EN 61094-4-1996 Specification for measurement microphones - Specifications for working standard microphones《测量规范 第4部分 工作标准传声器规范》.pdf
  • BS EN 61094-5-2016 Electroacoustics Measurement microphones Methods for pressure calibration of working standard microphones by comparison《电声学 测量传声器 用比较片做用工作标准传声器的压力校准方法》.pdf BS EN 61094-5-2016 Electroacoustics Measurement microphones Methods for pressure calibration of working standard microphones by comparison《电声学 测量传声器 用比较片做用工作标准传声器的压力校准方法》.pdf
  • BS EN 61094-6-2005 Measurement microphones - Electrostatic actuators for determination of frequency response《测量传声器 频率响应的测定用静电促动器》.pdf BS EN 61094-6-2005 Measurement microphones - Electrostatic actuators for determination of frequency response《测量传声器 频率响应的测定用静电促动器》.pdf
  • 相关搜索

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

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