【计算机类职业资格】二级C++笔试-305及答案解析.doc
《【计算机类职业资格】二级C++笔试-305及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】二级C++笔试-305及答案解析.doc(33页珍藏版)》请在麦多课文档分享上搜索。
1、二级 C+笔试-305 及答案解析(总分:100.00,做题时间:90 分钟)一、选择题(总题数:30,分数:70.00)1.以下内容属于存储在计算机内有结构的数据集合的是( )。(分数:2.00)A.数据库系统B.数据库C.数据库管理系统D.数据结构2.编制好的程序,首先要确保它的正确性和可靠性,还应强调良好的编程风格。在书写功能性注解时应考虑( )。(分数:2.00)A.仅为整个程序作注解B.仅为每个模块作注解C.为程序段作注解D.为每个语句作注解3.若有以下程序:#include iostreamusing namespace std;class Baseint x;protected:
2、int y;public:int z;void setx(int i)x=i;int getx ( )return x;class Inherit : private Baseprivate:int m;public:int p;void setvalue(int a,int b,int c, int d) setx((分数:2.00)A.;class Basepublic:void fun ()cout“Base: :fun“end1;class Derived : public Basepublic:void fun ( )cout“Derived: :fun“end1;int main
3、( )Base a,*pb;Derived b;_;pb-fun(); /调用基类的成员函数 fun()return 0 ;(分数:2.00)A.pb=private:int data;class Derive : public Basepublic:Derive() : Base(O)Derive (int x)d=x;void setvalue(int i)data=i;private:d;(分数:2.00)A.1B.2C.3D.47.设有关系 R 及关系 S,它们分别有 p、q 个元组,则关系 R 与 S 经笛卡儿积后所得新关系的元组个数是( )。(分数:2.00)A.pB.qC.p+q
4、D.p*q8.以下各选项中,( )中都是 C+语言保留字。(分数:2.00)A.cout,operator,thisB.short,string,staticC.if,while,=D.private,public,printf9.在一个单链表中,若 q 节点是 p 节点的前驱节点,若在 q 与 p 之间插入节点 s,则执行( )。(分数:2.00)A.sqink=plink; plink=sB.plink=s; sqink=qC.plink=slink; slink=pD.qlink=s; slink=p10.利用 ER 模型进行数据库的概念设计,可以分成 3 步:首先设计局部 ER 模型,
5、然后把各个局部 ER 模型综合成一个全局的模型,最后对全局 ER 模型进行( )。(分数:2.00)A.简化B.结构化C.最小化D.优化11.有以下程序:#include iostreamusing namespace std;class sampleprivate:int n;public:sample()sample (int m)n=m;sample add(sample sl,sample s2)this-n=sl.n+s2.n;return (*this);void disp()cout“n=“nend1;int main ( )sample sl(10) ,s2 (5),s3;s3
6、.add(s1,s2);s3.disp();return 0;程序运行后,输出的结果是( )。(分数:2.00)A.n=10B.n=5C.n=20D.n=1512.以下程序执行后的输出结果是( )。#include iostreamusing namespace std;void try(int,int,int,int);int main ( )int x,y,z,r;x=1;y=2;try(x,y,z,r);coutrend1;return 0;void try(int x,int y, int z,int r)z = x+y;x = X*X;y = y*y;r = z+x+y;(分数:2.
7、00)A.18B.9C.10D.不确定13.有如下类的定义。空格处的语句是( )。class MyClass_ int x, y;public:MyClass(int a=0,int b=0)x=a;y=b;static void change()x-=10;y-=10;(分数:2.00)A.staticB.constC.privateD.不需要填入内容14.有以下程序:#include iostreamusing namespace std;int main ()int n;cinn;if (n+10)coutnend1;elsecoutn-end1;return 0;若执行该程序时从键盘上
8、输入 9,则输出结果是( )。(分数:2.00)A.11B.10C.9D.815.假定 MyClass 为一个类,则该类的拷贝构造函数的声明语句为 ( )。(分数:2.00)A.MyClassB.MyClass (MyClass x);C.MyClass(MyClass D.MyClass (MyClass *x);16.有以下程序:#includeiostreamusing namespace std;class Aprivate:int x;public:A(int(分数:2.00)A.protected:int z;public:class Embedprivate:int y;publ
9、ic:Embed ( )y=100;int Embed_Fun();MyEmbed;int Contain_Fun();;下列对上面定义的描述中,正确的是( )。(分数:2.00)A.定义类 Embed 对象的语句是:Contain:Embed Myobject;B.类 Contain 的成员函数 Contain_Fun()中可以访问对象 MyEmbed 的私有成员 yC.类 Embed 的成员函数 Embed_Fun()中可以直接访问类 Contain 的所有成员D.类 Embed 的成员函数 Embed_Fun()中只能直接访问类 Contain 的公有成员19.C+流中重载了运算符,它是
10、一个( )。(分数:2.00)A.用于输出操作的成员函数B.用于输入操作的成员函数C.用于输入操作的非成员函数D.用于输出操作的非成员函数20.已知枚举类型定义语句为:enum Token NAME,NUMBER,PLUS=5,MINUS,PRINT=10;则下列说法中,错误的是( )。(分数:2.00)A.枚举常量 NAME 的值为 1B.枚举常量 NUMBER 的值为 1C.枚举常量 MINUS 的值为 6D.枚举常量 PRINT 的值为 1021.有以下程序:#include iostreamusing namespace std;int main ( )int n3,i,j,k = 2
11、;for(i = 0;ik;i+)ni = O;for(i = O;ik;i+)for(j = O;jk;j+)nj = ni + 1;coutn 0 end1;return 0;上述程序运行后,输出结果是( )。(分数:3.00)A.0B.1C.2D.322.若有以下程序:#include iostreamusing namespace std;int main()int a=3;cout(a+=a-=a+(分数:3.00)A.end1;return 0;程序执行后的输出结果是( )。A) -6B.12C.0D.-1223.算法的空间复杂度是指( )。(分数:3.00)A.算法程序的长度B.
12、算法程序中的指令条数C.算法程序所占的存储空间D.算法执行过程中所需要的存储空间24.设有语句:char str1=“string“,str28,*str3,*str4=“string“;则下列对库函数 strcpy()调用不正确的是( )。(分数:3.00)A.strcpy(str1,“Hell01“);B.strcpy(str2,“Hell02“);C.strcpy(str3,“Hell03“);D.strcpy(str4,“Hell04“);25.下列函数中,哪项是正确的递归函数( )。A int Fun(int n)if(n1) return 1;else return n*Fun(n
13、+1);B) int Fun(ira n)if(abs(n)1) return 1;else return n*Fun(n/2);C) int Fun(int n)if(n1) return 1;else return n*Fun(n*2)1D) int Fun(int n)if(n1) return 1;else retun n*Fun(n-1);(分数:3.00)A.B.C.D.26.在进行单元测试时,常用的方法是( )。(分数:3.00)A.采用白盒测试,辅之以黑盒测试B.采用黑盒测试,辅之以白盒测试C.只使用白盒测试D.只使用黑盒测试27.以下函数实现的功能是 ( )。void fun
14、(char *s)char *p,*q, temp;p=s;q=s+strlen (s) -1;while (pq)temp=*p;*p=*q;*p=temp;p+;q-;(分数:3.00)A.将一个字符串首尾颠倒B.计算字符串的长度C.统计字符串中的空格个数D.将字符串中的小写字母变成大写字母28.一个满二叉树其深度为 4,则其叶子节点的个数为( )。(分数:3.00)A.8B.16C.32D.429.以下程序段有( )处错误。#include iostreamusing namespaces std;class Sampleprivate:int n;public:Sample (int
15、in=i;void setvalue(int i)n=i;void display()cout“n=“nend1;int main ( )const Sample a(lO);a. setvalue (5);a.display();return 0;(分数:3.00)A.1B.2C.3D.430.下面几种调试方法中,不适合调试大规模程序的是( )。(分数:3.00)A.强行排错法B.回溯法C.原因排除法D.静态调试二、填空题(总题数:13,分数:30.00)31.数据的逻辑结构可用一个二元组 B(K,R)来表示,其中 K 是 【1】 ,R 是 【2】 。(分数:4.00)填空项 1:_32.设
16、栈 S 和队列 Q 的初始状态为空,元素 e1、e2、e3、e4、e5 和 e6 依次通过栈 S,一个元素出栈后即进入队列 Q,若 6 个元素出队的顺序是 e2、e4、e3、e6、e5、e1,则栈 S 的容量至少应是 【3】 。(分数:2.00)填空项 1:_33.下图所示的二叉树的先序遍历序列是 【4】 。(分数:2.00)填空项 1:_34.数据库管理系统是位于 【5】 之间的软件系统。(分数:2.00)填空项 1:_35.有以下程序:#include iostreamusing namespace std;int main()int i=010,j=10;cout(+i)“,“i-end
17、1;return 0;则该程序运行后的输出结果是 【6】 。(分数:2.00)填空项 1:_36.设有以下程序:#includeiostreamusing namespace std;int main()int a,b,k:4,m=6,*p1=if (yz)a=y;y=z;z=a;if (xy)a=x;x=y;y=a;(分数:2.00)填空项 1:_42.以下程序运行后的输出结果是 【14】 。#include iostream#include stringusing namespace std;class Y;class Xint x;char *strx;public:X(int a, c
18、har *str)x=a;strx=new charstrlen(str)+l;strcpy(strx,str);void show(Y ;class Yprivate:int y;char *stry;public:Y(int b,char *str)y=b;stry=new charstrlen(str)+l;strcpy(stry, str);friend void X:show(Y ;void X:show(Y coutob.stryend1;int main()X a(10,“stringX“);Y b(20,“stringY“);a. show (B) ;return 0;(分数:
19、2.00)填空项 1:_43.若有以下程序:#include iostreamusing namespace std;#define PI 3.14class Pointprivate:int x,y;public:Point (int a,int b) x=a;y=b;int getx ()return x;int gety()return y;class Circle : public Pointint r;public:Circle(int a, int b,int C) : Point (a, b) r=c;int getr()return r;double area()return
20、PI*r*r;int main()Circle c1(5,7,10);coutc1.area()end1;return 0;程序执行后的输出结果是 【15】 。(分数:2.00)填空项 1:_二级 C+笔试-305 答案解析(总分:100.00,做题时间:90 分钟)一、选择题(总题数:30,分数:70.00)1.以下内容属于存储在计算机内有结构的数据集合的是( )。(分数:2.00)A.数据库系统B.数据库 C.数据库管理系统D.数据结构解析:解析 本题考查考生对几个概念的理解。其中数据库系统是指数据库和数据库管理系统软件的合称。数据库管理系统是一个帮助用户创建和管理数据库的应用程序的集合。
21、数据结构描述数据的类型、内容、性质以及数据间的联系。数据库是指存储在计算机内有结构的数据集合。2.编制好的程序,首先要确保它的正确性和可靠性,还应强调良好的编程风格。在书写功能性注解时应考虑( )。(分数:2.00)A.仅为整个程序作注解B.仅为每个模块作注解C.为程序段作注解 D.为每个语句作注解解析:解析 首先应该知道功能性注释是嵌在源程序体中的,用以描述其后的语句或程序段是在做什么工作,或是执行了下面的语句会怎么样。所以它描述的是一段程序,而不是每一个语句,是为程序段作注解。3.若有以下程序:#include iostreamusing namespace std;class Basei
22、nt x;protected:int y;public:int z;void setx(int i)x=i;int getx ( )return x;class Inherit : private Baseprivate:int m;public:int p;void setvalue(int a,int b,int c, int d) setx((分数:2.00)A.;class Basepublic:void fun ()cout“Base: :fun“end1;class Derived : public Basepublic:void fun ( )cout“Derived: :fun
23、“end1;int main ( )Base a,*pb;Derived b;_;pb-fun(); /调用基类的成员函数 fun()return 0 ;(分数:2.00)A.pb=private:int data;class Derive : public Basepublic:Derive() : Base(O)Derive (int x)d=x;void setvalue(int i)data=i;private:d;(分数:2.00)A.1B.2 C.3D.4解析:解析 本题考核派生类的定义和成员的访问权限。第 1 处错误:在派生类的构造函数 Derive(intx)中没有调用基类的构
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 二级 笔试 305 答案 解析 DOC
