[计算机类试卷]国家二级(C++)机试模拟试卷147及答案与解析.doc
《[计算机类试卷]国家二级(C++)机试模拟试卷147及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级(C++)机试模拟试卷147及答案与解析.doc(31页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级( C+)机试模拟试卷 147及答案与解析 一、选择题 1 下列叙述中正确的是 ( )。 ( A)栈是 “先进先出 ”的线性表 ( B)队列是 “先进后出 ”的线性表 ( C)循环队列是非线性结构 ( D)有序线性表既可以采用顺序存储结构,也可以采用链式存储结构 2 支持子程序调用的数据结构是 ( )。 ( A)栈 ( B)树 ( C)队列 ( D)二 - Z树 3 某二叉树有 5个度为 2的结点,则该二叉树中的叶子结点数是 ( )。 ( A) 10 ( B) 8 ( C) 6 ( D) 4 4 下列排序方法中,最坏情况下比较次数最少的是 ( )。 ( A)冒泡排序 ( B)简单选择排
2、序 ( C)直接插入排序 ( D)堆排序 5 软件按功能可以分为:应用软件、系统软件和支撑软件 (或工具软件 )。下面属于应用软件的是 ( )。 ( A)编译程序 ( B)操作系统 ( C)教务管理系统 ( D)汇编程序 6 下面叙述中错误的是 ( )。 ( A)软件测试的目的是发现错误并改正错误 ( B)对被调试的程序进行 “错误定位 ”是程序调试的必要步骤 ( C)程序调试通常也称为 Debug ( D)软件测试应严格执行测试计划,排除测试的随意性 7 耦合性和内聚性是对模块独立性度量的两个标准。下列叙述中正确的是 ( )。 ( A)提高耦合性降低内聚性有利于提高模块的独立性 ( B)降低
3、耦合性提高内聚性有利于提高模块的独立性 ( C)耦合性是指一个模块内部各个元素间彼此结合的紧密程度 ( D)内聚性是指模块间互相连接的紧密程度 8 数据库应用系统中的核心问题是 ( )。 ( A)数据库设计 ( B)数据库系统设计 ( C)数据库维护 ( D)数据库管理员培训 9 有两个关系 R, S如下 : 由关系 R通过运算得到关系S,则所使用的运算为 ( )。 ( A)选择 ( B)投影 ( C)插入 ( D)连接 10 将 E-R图转换为关系模式时,实体和联系都可以表示为 ( )。 ( A)属性 ( B)键 ( C)关系 ( D)域 11 字面常量 42、 4 2、 42L的数据类型分
4、别是 ( )。 ( A) long、 double、 int ( B): long、 float、 int ( C) int、 double、 long ( D) int、 float、 long 12 执行下列语句段后,输出字符 “*”的个数是 ( )。 for(int i=50; il; -i) cout using namespace std; class A public: static int a; void init()a=1; A(int a=2)init(); a+; ; int A: a=0; A obj; int main() cout using namespace st
5、d; class test private: int a; public: test()cout using namespace std; class Point public: static int number; public: Point()number+; Point()number-; ; int Point: number=0; int main() Point*ptr; Point A, B; Point*ptr_point=new Point3; ptr=ptr_point; Point C: Cout using namespace std; class Sample fri
6、end long fun(Sample s); public: Sample(long a)x=a; private: long x; ; long fun(Sample s) if(s x using namespace std; class A public: A(int i)x=i; void dispa()cout using namespaee std; class Music public: void setTitle(char, -str)strcpy(title, str); protected: char type10; private: char title20; ; cl
7、asg Jazz: public Music public: void set(char*str) strcpy(type, “Jazz“); strcpy(title, str); ; 下列叙述中正确的是 ( )。 ( A)程序编译正确 ( B)程序编译时语句 出错 ( C) 程序编译时语句 出错 ( D)程序编译时语句 和 都出错 36 有如下程序: #include using namespace std; class Book public: Book(char*t=“ “)strcpy(title, t); private: char title40; ; class Novel:
8、public Book public: Novel(char*t=“ “): Book(t) char*Category()constreturn“文学 “; ; int main() Book*pb; pb=new Novel(); coutCategory(); delete pb; return 0; 若程序运行时输出结果是 “文学 ”,则横线处缺失的语句是 ( )。 ( A) char*Category(); ( B) char*Category()const; ( C) virtual char*Category()const; ( D) virtual char*Category(
9、)const=0; 37 如下函数模板: templateT square(T x)return x*x; 其中 T是 ( )。 ( A)函数形参 ( B)函数实参 ( C)模板形参 ( D)模板实参 38 下列函数模板的定义中,合法的是 ( )。 ( A) templateT abs(T X) return xT abs(T X)return xabs(T x)return x using namespace std; class MyClass int value; public: ERROR * found * void MyClass(int val): value(val) int
10、GetValue()constreturn value; void SetValue(int val); ; ERROR * found * inline void SetValue(int val)value=val; int main() MyClass obj(0); obj SetValue(10); ERROR * found * 下列语句功能是输出 obj的成员 value的值 cout class vehicle private: int MaxSpeed; int Weight; public: *found* vehicle(int maxspeed, int weight)
11、: _ vehicle(); int getMaxSpeed()return MaxSpeed; int getWeight()return Weight; ; *found* class bicycle: _public vehicle f private: int Height; public: bicycle(int maxspeed, int weight, int height): vehicle maxspeed, weight),Height(height) int getHeight()return Height; ; ; *found* class motorcar: _pu
12、blic vehicle private: int SeatNum; public: motorcar(int maxspeed, int weight, int seatnum): vehicle(maxspeed, weight),SeatNum(seatnum) int getSeatNum()return SeatNum; ; ; *found* class motorcycle: _ public: motorcyele(int maxspeed, int weight, int height): Vehicle(maxspeed, weight),bicYcle maxspeed,
13、 weight, height), motorcar(maxspeed, weight, 1) ; void main() motorcycle a(80, 150, 100); cout #include using namespaee std; class MiniString public: friend ostream&operator(istream&input, MiniString&s)重载流提取运算符 char temp100; 用于输入的临时数组 temp0= 0;初始为空字符串 inputsetw(100)temp; int inLen=strlen(temp);输入字符串
14、长度 if(inLen!=0) s length=inLen;赋长度 if(S sPtr!=0)deletes sPtr;避免内存泄漏 s sPtr=new chars length+1; strepy(S sPtr, temp);如果 s不 是空指针,则复制内容 else s sPtr0= 0;如果 s是空指针,则为空字符串 return input; void modString(const char*string2)更改字符串内容 if(string2 !=0)如果 string2不是空指针,则复制内容 if(strlen(stringe2)!=length) length=strlen
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 模拟 147 答案 解析 DOC
