【计算机类职业资格】全国计算机等级考试二级C++真题题库1+2014年3月及答案解析.doc

上传人:syndromehi216 文档编号:1329640 上传时间:2019-10-17 格式:DOC 页数:16 大小:90KB
下载 相关 举报
【计算机类职业资格】全国计算机等级考试二级C++真题题库1+2014年3月及答案解析.doc_第1页
第1页 / 共16页
【计算机类职业资格】全国计算机等级考试二级C++真题题库1+2014年3月及答案解析.doc_第2页
第2页 / 共16页
【计算机类职业资格】全国计算机等级考试二级C++真题题库1+2014年3月及答案解析.doc_第3页
第3页 / 共16页
【计算机类职业资格】全国计算机等级考试二级C++真题题库1+2014年3月及答案解析.doc_第4页
第4页 / 共16页
【计算机类职业资格】全国计算机等级考试二级C++真题题库1+2014年3月及答案解析.doc_第5页
第5页 / 共16页
点击查看更多>>
资源描述

1、全国计算机等级考试二级 C+真题题库 1+2014 年 3 月及答案解析(总分:100.00,做题时间:120 分钟)一、选择题(每小题 1 分,共 40 分)(总题数:40,分数:40.00)1.一个教师可讲授多门课程,一门课程可由多个教师讲授。则实体教师和课程间的联系是( )。(分数:1.00)A.1:1 联系B.1:m 联系C.m:1 联系D.m:n 联系2.Tilil 程序的运行结果是( )。 #include void main() int i=1: while(i”,使得程序中可以“cinobj;”的形式改变 MyClass 类的对象 0bj 中数据成员 data 的值,则横线处的

2、声明语句应为( )。(分数:1.00)A.friend istream& operator(istream&is,MyClass&A;B.friend istream&operator(istream&is,MyClass A;C.istream&operator(istream&is,MyClass&A;D.istream&operator(istream&is,MyClass A;34.有如下程序: #inClude using namespaCe std; Class Sample friend long fun(Sample S); publiC: Sample(10ng Ax=a;

3、private: long X; ; long fun(Sample S) if(Sxname,nanle); /*found* const char*getName()constreturn name;/返回部门名称 /*found* const char*getOffice()const_ /返回办公室房号 void changeOfficeTo(const char*office) /改换为指定房号的另一个办公室 strcpy(this 一office,office); private: char name20;/部门名称 char office20;/部门所在办公室房号 ; class

4、 staff/“职工”类 public: /*found* Staff(const char*myid,const char 木 my_name,Department&my_dept): strcpy(this 一staff id,my_id); strcpy(this 一name,my_name); const char*getlD()constreturn staff_id; const char*getName()conslreturn name; Department getDepartment()constreturn dept; char staff=id10;/职工号 char

5、name20;/姓名 Department&dept;/所在部门 ; void showStaff(Staff&staff) cout=elemj 一 1)break; /如果找到的是等于 element 的元素,说明要添加的元素已经存在,直接返回 if(j0) if(element=elemj-1)return; /如果找到的是小于 element 的元素,j 就是要添加的位置 /该元素及其后面的元素依次后移,腾出插入位置 for(int k=counter;kj;k 一) elemk=elemk 一 1; elemj=element;/将 element 插入到该位置 counter+;

6、/计数器加 l void IntegerSet:remove(int element) /*333* /*666* void IntegerSet:show()const for(int i=0;i”,使得程序中可以“cinobj;”的形式改变 MyClass 类的对象 0bj 中数据成员 data 的值,则横线处的声明语句应为( )。(分数:1.00)A.friend istream& operator(istream&is,MyClass&A; B.friend istream&operator(istream&is,MyClass A;C.istream&operator(istream

7、is,MyClass&A;D.istream&operator(istream&is,MyClass A;解析:本题考查重载流运算符“”,根据重载规则,本题答案为 A。34.有如下程序: #inClude using namespaCe std; Class Sample friend long fun(Sample S); publiC: Sample(10ng Ax=a; private: long X; ; long fun(Sample S) if(Sxname,nanle); /*found* const char*getName()constreturn name;/返回部门名称

8、 /*found* const char*getOffice()const_ /返回办公室房号 void changeOfficeTo(const char*office) /改换为指定房号的另一个办公室 strcpy(this 一office,office); private: char name20;/部门名称 char office20;/部门所在办公室房号 ; class staff/“职工”类 public: /*found* Staff(const char*myid,const char 木 my_name,Department&my_dept): strcpy(this 一st

9、aff id,my_id); strcpy(this 一name,my_name); const char*getlD()constreturn staff_id; const char*getName()conslreturn name; Department getDepartment()constreturn dept; char staff=id10;/职工号 char name20;/姓名 Department&dept;/所在部门 ; void showStaff(Staff&staff) coutoffice,office); (2)return office; (3)dept(

10、my_dept) (4)deptchangeOfficeTo(”311”);)解析:四、综合应用题(18 分)(总题数:1,分数:18.00)43.请使用 VC6 或使用【答题】菜单打开考生文件夹 proj3 下的工程 proj3,其中包含了类 IntegerSet 和主函数 main 的定义。一个 IntegerSet 对象就是一个整数的集合,其中包含 0 个或多个无重复的整数;为了便于进行集合操作,这些整数按升序存放在成员数组 elem 的前若干单元中。成员函数 add 的作用是将一个元素添加到集合中(如果集合中不存在该元素),成员函数 remove 从集合中删除指定的元素(如果集合中存在

11、该元素)。请编写成员函数 remove。在 main 函数中给出了一组测试数据,此时程序的正确输出结果应为: 2 3 4 5 27 28 31 66 75 2 3 4 5 6 27 28 31 56 75 2 3 4 5 6 19 27 28 31 66 75 3 4 5 6 19 27 28 31 66 75 3 4 5 6 19 27 28 31 66 75 要求: 补充编制的内容写在“/*333*”与“/*666*”之间,不得修改程序的其他部分。注意:程序最后将结果输出到文件 outdat 中。输出函数 writeToFile 已经编译为 obj 文件,并且在本程序中调用。 /Integ

12、orSeth #ifndef INTEGERSET #define INTEGERSET #include using namespace std; const int MAXELEMENTS=100; /集合最多可拥有的元素个数 class IntegerSet int elemMAXELEMENTS; /用于存放集合元素的数组 int counter; /用于记录集合中元素个数的计数器 puhlic: IntegerSet():counter(0) /创建一个空集合 IntegerSet(int data,int size); /利用数组提供的数据创建一个整数集合 void add(int

13、 element); /添加一个元素到集合中 void remeve(int element); /删除集合中指定的元素 int getCount()constreturn counter; /返回集合中元素的个数 int getElement(int i)constretum elemi;/返回集合中指定的元素 void show()const; ; void WriteToFile(char*); #endif /maincpp #include”IntegerSeth” #include IntegerSet:IntegerSet(int data,int size):counter(0

14、) for(int i=0;i0;j-) if(element=elemj 一 1)break; /如果找到的是等于 element 的元素,说明要添加的元素已经存在,直接返回 if(j0) if(element=elemj-1)return; /如果找到的是小于 element 的元素,j 就是要添加的位置 /该元素及其后面的元素依次后移,腾出插入位置 for(int k=counter;kj;k 一) elemk=elemk 一 1; elemj=element;/将 element 插入到该位置 counter+; /计数器加 l void IntegerSet:remove(int element) /*333* /*666* void IntegerSet:show()const for(int i=0;isetw(4)_正确答案:(for(int i=0:i解析:

展开阅读全文
相关资源
猜你喜欢
  • ASTM D4185-2017 Standard Test Method for Measurement of Metals in Workplace Atmospheres by Flame Atomic Absorption Spectrophotometry《用火焰原子吸收分光光度法测定工作场所大气中金属的标准试验方法》.pdf ASTM D4185-2017 Standard Test Method for Measurement of Metals in Workplace Atmospheres by Flame Atomic Absorption Spectrophotometry《用火焰原子吸收分光光度法测定工作场所大气中金属的标准试验方法》.pdf
  • ASTM D4186 D4186M-2012 Standard Test Method for One-Dimensional Consolidation Properties of Saturated Cohesive Soils Using Controlled-Strain Loading《用可控应变荷载测试饱和粘性土单维固结特性的标准试验方法》.pdf ASTM D4186 D4186M-2012 Standard Test Method for One-Dimensional Consolidation Properties of Saturated Cohesive Soils Using Controlled-Strain Loading《用可控应变荷载测试饱和粘性土单维固结特性的标准试验方法》.pdf
  • ASTM D4186 D4186M-2012e1 Standard Test Method for One-Dimensional Consolidation Properties of Saturated Cohesive Soils Using Controlled-Strain Loading《用可控应变荷载法的饱和性粘土的单向压实性能的标准试验方法》.pdf ASTM D4186 D4186M-2012e1 Standard Test Method for One-Dimensional Consolidation Properties of Saturated Cohesive Soils Using Controlled-Strain Loading《用可控应变荷载法的饱和性粘土的单向压实性能的标准试验方法》.pdf
  • ASTM D4186-2006 Standard Test Method for One-Dimensional Consolidation Properties of Saturated Cohesive Soils Using Controlled-Strain Loading《用可控应变荷载测试饱和粘性土单维固结性能的标准试验方法》.pdf ASTM D4186-2006 Standard Test Method for One-Dimensional Consolidation Properties of Saturated Cohesive Soils Using Controlled-Strain Loading《用可控应变荷载测试饱和粘性土单维固结性能的标准试验方法》.pdf
  • ASTM D4188-1982(2003) Standard Practice for Performing Pressure In-Line Coagulation-Flocculation-Filtration Test《在线加压凝结-絮凝-过滤试验》.pdf ASTM D4188-1982(2003) Standard Practice for Performing Pressure In-Line Coagulation-Flocculation-Filtration Test《在线加压凝结-絮凝-过滤试验》.pdf
  • ASTM D4188-2008 Standard Practice for Performing Pressure In-Line Coagulation-Flocculation-Filtration Test《在线加压凝结-絮凝-过滤试验标准实施规程》.pdf ASTM D4188-2008 Standard Practice for Performing Pressure In-Line Coagulation-Flocculation-Filtration Test《在线加压凝结-絮凝-过滤试验标准实施规程》.pdf
  • ASTM D4188-2013 Standard Practice for Performing Pressure In-Line Coagulation-Flocculation-Filtration Test in Water《在线加压凝结-絮凝-过滤水中试验标准操作规程》.pdf ASTM D4188-2013 Standard Practice for Performing Pressure In-Line Coagulation-Flocculation-Filtration Test in Water《在线加压凝结-絮凝-过滤水中试验标准操作规程》.pdf
  • ASTM D4188-2017 Standard Practice for Performing Pressure In-Line Coagulation-Flocculation-Filtration Test in Water《水中进行压力在线混凝絮凝过滤试验的标准实施规程》.pdf ASTM D4188-2017 Standard Practice for Performing Pressure In-Line Coagulation-Flocculation-Filtration Test in Water《水中进行压力在线混凝絮凝过滤试验的标准实施规程》.pdf
  • ASTM D4189-2007 Standard Test Method for Silt Density Index (SDI) of Water《水的淤泥密度指数(SDI)的标准试验方法》.pdf ASTM D4189-2007 Standard Test Method for Silt Density Index (SDI) of Water《水的淤泥密度指数(SDI)的标准试验方法》.pdf
  • 相关搜索

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

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