【计算机类职业资格】二级C++笔试13及答案解析.doc
《【计算机类职业资格】二级C++笔试13及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】二级C++笔试13及答案解析.doc(15页珍藏版)》请在麦多课文档分享上搜索。
1、二级 C+笔试 13 及答案解析(总分:88.00,做题时间:90 分钟)一、B选择题/B(总题数:30,分数:60.00)1.若有以下程序: #include iostream using namespace std; int main() int a4 4 = 1,2,3,-4,0,-12,-13,14, -21,23,0,-24,-31,32,-33,0; int i,j,s = 0; for(i=0;i4;i+) for(j=O;j4;j+) if(ai j =0) continue; s+=a i j; coutsend1; return 0; 执行后的输出结果是( )。(分数:2.
2、00)A.-138B.141C.75D.-12.若有如下程序: #include iostream using namespace std; int main() char *p=“abcdefgh“,*r; long *q; q=(long *)p; q+; r=(char *)q; coutrend1; return 0; 上述程序的输出结果是( )。(分数:2.00)A.abcdefghB.0C.abcdD.efgh3.若有以下程序: #include iostream using namespace std; class Base private: int a,b; public: B
3、ase(int x, int y) a=x; b=y; void disp () couta“ “bend1; ; class Derived : public Base private: int c; int d; public: Derived(int x,int y, int z,int m) :Base(x,y) c=z; d=m; void disp () coutc“ “dend1; ; int main() Base b(5,5),*pb; Derived obj(1,2,3,4); pb= pb-disp(); return 0; 执行程序后的输出结果是( )。(分数:2.00
4、)A.1,2B.3,4C.2,3D.5,54.有以下程序: #include iostream using namespace std; class sample private: int x; public: void setx(int i) x=i; int putx () return x; ; int main ( ) sample *p; sample A3; A0 .setx(5); A1 .setx (6); A2 .setx(7); for (int j=0;j3;j+) p= coutp-putx () “, “; coutend1; return 0; 执行后执行结果是(
5、)。(分数:2.00)A.5,6,7,B.5,5,5,C.6,6,6,D.7,7,7,5.有以下程序: #include iostream using namespace std; class R public: R(int f1,int r2) R1=r1; R2=r2; void print(); void print ()const; private: int R1, R2; ; void R: :print() coutR1“, “R2end1; void R: :print() const coutRl“, “R2end1; int main () R a(5,4); const R
6、 b(20,52); b.print (); return 0; 执行后的输出结果是(分数:2.00)A.5,4B.20,52C.0,0D.4,56.有以下程序: #include iostream using namespace std; int main() int intone; int intone=5; rInt=7; coutintOne“,“rIntend1; return 0; 上述程序执行后的输出结果是( )。(分数:2.00)A.5,7B.7,5C.5,5D.7,77.下列关于构造函数的描述中,错误的是( )。(分数:2.00)A.构造函数可以设置默认参数B.构造函数在定义
7、类对象时自动执行C.构造函数可以是内联函数D.构造函数不可以重载8.下列关于指针运算的描述中,错误的是( )。(分数:2.00)A.在一定条件下,两个指针可以相加B.在一定条件下,两个指针可以进行逻辑判断C.在一定条件下,指针可以为空值D.在一定条件下,两个指针可以相互赋值9.下列变量定义中,合法的是( )。(分数:2.00)A.short_a=1-1e-1;B.doubleb=1+5e2.5;C.long do=0xfdaL;D.float2_and=1-e-3;10.在关系数据库中,用来表示实体之间联系的是( )。(分数:2.00)A.树结构B.网结构C.线形表D.二维表11.下面是“二维
8、向量” vector2D 的定义,其中作为成员函数重载的运算符“+”的功能是将两向量的分量 x 和 y 对应相加,然后返回作为相加结果的新对象。那么应该在横线上填入的语句是( )。 class vector2D private: double x; /x 分量 double y; /y 分量 public: vector2D(double x0=0,double y0=0) :x(x0),y(y0) void show(cout (, y) ; _; ; vector2D : operator + (vector2D a) return vector20(x+a.x,y+a.y); (分数:2
9、.00)A.vector2D operator + (vector2DB.vector2D operator + (vector2D couti; void print() coutiend1; ; class ClassTwo public: ClassTwo(int v=O) i=v;couti; void print() coutiend1; private: ClassOne myObj; int i; ; void main() ClassTwo obj(1); obj.print(); (分数:2.00)A.011B.111C.110D.10114.下列关于 C+运算符结合性的说法
10、中,正确的是( )。(分数:2.00)A.赋值运算符是左结合的B.复合运算符是左结合的C.单目运算符是左结合的D.双目算术运算符是左结合的15.有以下程序: #include iostream #include string using namespace std; class Y; class X private: int x; char *strx; public: X(int a, char *str) x=a; strx=new charstrlen(str)+1; strcpy(strx,str); void show(Y ; class Y private: int y; char
11、 *stry; public: Y(int b,char *str) y=b; stry=new charstrlen(str)+1; strcpy(stry, str); friend void X: :show(Y ; void X: :show(Y coutob, stryend1; int main ( ) X a(10,“X“); Y b (20, “Y“); a. show(B) ; return 0; 执行后的输出结果是( )。(分数:2.00)A.X,YB.a,bC.X,XD.Y,Y16.下面这个程序段的时间复杂度是( )。 for (i=1; in; i+) y=y+1; f
12、or (j=0;j=(2*n);j+) X+; (分数:2.00)A.O(10g2B.O(C.0(nlog2D.O(n2)17.需求分析阶段最后提供的文档是软件的( )。(分数:2.00)A.功能说明书B.加工说明书C.可行性分析报告D.需求规格说明书18.以下过程设计工具不属于图形工具的是( )。(分数:2.00)A.程序流程图B.PADC.HIPOD.PDL19.下列关于虚函数的说法中,正确的是( )。(分数:2.00)A.如果在重定义虚函数时使用了保留字 virtual,则该重定义函数仍然是虚函数B.虚函数不得声明为静态函数C.虚函数不得声明为另一个类的私有函数D.派生类必须重新定义基类
13、的虚函数20.在一个容量为 10 的循环队列中,若头指针为 6,尾指针为 1,则此时该循环队列中共有的元素个数为( )。(分数:2.00)A.4B.5C.6D.721.以下方法不属于结构化分析方法的是( )。(分数:2.00)A.面向数据流的结构化分析方法B.面向数据结构的 Jackson 方法C.面向数据结构的结构化数据系统开发方法D.面向对象的分析方法22.在一个长度为 n 的线性表中插入一个元素,最好情况下需要移动的数据元素数目(分数:2.00)A.0B.1C.nD.n/223.若有以下程序: #include iostream using namespace std; #define
14、PI 3.14 class Point private: int x,y; public: Point(int a,int b) x=a; y=b; int getx() return x; int gety() return y; ; class Circle : public Point private: int r; public: Circle(int a, int b,int c) :Point(a,b) r=c; int getr() return r; double area() return PI*r*r; ; int main() Circle c1(5,7,10); cou
15、tc1.area()end1; return 0; 程序执行后的输出结果是( )。(分数:2.00)A.314B.157C.78.5D.153.8624.下列描述中,表达错误的是( )。(分数:2.00)A.公有继承时基类中的 public 成员在派生类中仍是 public 的B.公有继承时基类中的 private 成员在派生类中仍是 private 的C.公有继承时基类中的 protected 成员在派生类中仍是 protected 的D.私有继承时基类中的 public 成员在派生类中是 private 的25.下列关于静态数据成员的描述中,正确的是( )。(分数:2.00)A.静态数据成
16、员是类的所有对象共享的数据B.类的每个对象都有自己的静态数据成员C.类的不同对象有不同的静态数据成员值D.静态数据成员不能通过类的对象调用26.下列关于对象概念的描述中,错误的是( )。(分数:2.00)A.C+中的对象就是 C 语言中的结构变量B.对象代表着正在创建的系统中的一个实体C.对象是一个状态和操作(或方法)的封装体D.对象之间的信息传递是通过消息进行的27.对建立良好的程序设计风格,下面有关语句结构的描述中,错误的是( )。(分数:2.00)A.在一行内只写一条语句B.程序编写应优先考虑清晰性C.程序编写要做到效率第一,清晰第二D.避免不必要的转移28.有以下程序: #includ
17、e iostream using namespace std; void fun(int i,int j) cout(i+j)end1; void fun(int i) couti+end1; int main() int a=1; fun(A) ; return 0; 该程序执行后的输出结果是( )。(分数:2.00)A.1B.2C.3D.429.VisualFoxPro 是一种( )。(分数:2.00)A.数据库管理系统软件B.操作系统软件C.文字处理软件D.CAD 软件30.t 为 int 类型,进入下面的循环之前,t 的值为 0。 while(t=1) 则以下叙述中,正确的是( )。(
18、分数:2.00)A.循环控制表达式的值为 0B.循环控制表达式的值为 1C.循环控制表达式不合法D.以上说法都不对二、B填空题/B(总题数:14,分数:28.00)31.设有二维数组 A09,019,其每个元素占两个字节,第一个元素的存储地址为 100,若按行优先顺序存储,则元素 A6,6的存储地址为,U 【1】 /U。(分数:2.00)填空项 1:_32.软件工程概念的出现源自U 【2】 /U。(分数:2.00)填空项 1:_33.数据流图的类型有U 【3】 /U和事务型。(分数:2.00)填空项 1:_34.一个学生关系模式为(学号,姓名,班级号,),其中学号为关键词:一个班级关系模式为(
19、班级号,专业,教室,),其中班级号为关键词:则学生关系模式中的外关键词为U 【4】 /U。(分数:2.00)填空项 1:_35.从工程管理的角度来看,软件设计分两步来完成。首先是概要设计,然后是U 【5】 /U。(分数:2.00)填空项 1:_36.函数 YangHui 的功能是把杨辉三角形的数据赋给二位数组的下半三角,形式如下: (分数:2.00)填空项 1:_37.阅读下面程序: #includeiostream using namespace std; long fib(int n) if ( n 2 ) return (fib(n-1)+fib(n-2); else return 2;
20、 int main() coutfib(3)end1; return 0; 则该程序的输出结果应该是U 【8】 /U。(分数:2.00)填空项 1:_38.以下程序的输出结果是U 【9】 /U。 #includeiostream using namespace std; void fun() static int a=0; a+=2; couta; int main() int cc; for(cc=1;cc4;cc+) fun(); coutend1; return 0; (分数:2.00)填空项 1:_39.C+中,设置虚基类的目的是U 【10】 /U。(分数:2.00)填空项 1:_40
21、.C+语言中,派生类继承了基类的全部数据成员和除U 【11】 /U之外的全部函数成员。(分数:2.00)填空项 1:_41.虚函数必须是类的U 【12】 /U。(分数:2.00)填空项 1:_42.有如下程序: #include iostream using namespace std; template typename T T total( T *data) T s=0; while (*data) s+=*data+; return s; int main () int x=2,4,6, 8,0, 12, 14,16, 18 ; couttotal (x); return 0; 执行上面
22、程序的输出结果是U 【13】 /U。(分数:2.00)填空项 1:_43.有以下程序: #include iostream using namespace std; class sample int x; public: void setx(int i) x=i; int putx () return x; ; int main ( ) sample *p; sample A3; A0 .set:(5); A1 .setx(6); A2 .setx(7); for (int j=0;j3;j+) p= coutp-putx () “, “; coutend1; return 0; 执行后的输出
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 二级 笔试 13 答案 解析 DOC