[计算机类试卷]国家二级(C++)机试模拟试卷131及答案与解析.doc
《[计算机类试卷]国家二级(C++)机试模拟试卷131及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级(C++)机试模拟试卷131及答案与解析.doc(33页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级( C+)机试模拟试卷 131及答案与解析 一、选择题 1 下列叙述中正确的是 ( )。 ( A)数据的存储结构会影响算法的效率 ( B)算法设计只需考虑结果的可靠性 ( C)算法复杂度是指算法控制结构的复杂程度 ( D)算法复杂度是用算法中指令的条数来度量的 2 设数据集合为 D=1, 2, 3, 4, 5。下列数据结构 B=(D, R)中为非线性结构的是 ( )。 ( A) R=(1, 2), (2, 3), (3, 4), (4, 5) ( B) R=(1, 2), (2, 3), (4, 3), (3, 5) ( C) R=(5, 4), (4, 3), (3, 2), (2,
2、 1) ( D) R=(2, 5), (5, 4), (3, 2), (4, 3) 3 某二叉树共有 150个结点,其中有 50个度为 1的结点,则 ( )。 ( A)不存在这样的二叉树 ( B)该二叉树有 49个叶子结点 ( C)该二叉树有 50个叶子结点 ( D)该二叉树有 51个叶子结点 4 循环队列的存储空间为 Q(1: 50),初始状态为 front=rear=50。经过一系列正常的人队与退队操作后, front=rear=25,此后又正常地插入了一个元素,则 循环队列中的元素个数为 ( )。 ( A) 51 ( B) 50 ( C) 4 9 ( D) 1 5 下列排序方法中,最坏情
3、况下时间复杂度 (即比较次数 )低于 O(n2)的是 ( )。 ( A)快速排序 ( B)简单插入排序 ( C)冒泡排序 ( D)堆排序 6 下面描述正确的是 ( )。 ( A)软件测试是指动态测试 ( B)软件测试可以随机地选取测试数据 ( C)软件测试是保证软件质量的重要手段 ( D)软件测试的目的是发现和改正错误 7 下面图中属于软件设计建模工具的是 ( )。 ( A) DFD图 (数据流程图 ) ( B)程序流程图 (PFD图 ) ( C)用例图 (USE_CASE图 ) ( D)网络工程图 8 数据库 (DB)、数据库系统 (DBS)和数据库管理系统 (DBMS)之间的关系是 ( )
4、。 ( A) DB包括 DBS和 DBMS ( B) DBMS包括 DB和 DBS ( C) DBS包括 DB和 DBMS ( D) DBS、 DB和 DBMS相互独立 9 医院里有不同的科室,每名医生分属不同科室,则实体科室与实体医生间的联系是 ( )。 ( A)一对一 ( B)一对多 ( C)多对一 ( D)多对多 10 有 3个关系 R、 S和 T如下:则由关系 R和 S得到关系 T的操作是 ( )。 ( A)投影 ( B)选择 ( C)交 ( D)差 11 下列选项中,错误的 C+表达式是 ( )。 ( A) a+ ( B) b=10 ( C) double(3 5) ( D) x+!
5、=3 y 12 执行语句 “for(int i=0, x=0; !x&i using namespace std; int main() int sum=0: for(int i=1; i 18 下列关于运算符重载的表述中,错误的是 ( )。 ( A)不能为运算符重载函数改变其运算符原有的优先级; ( B)有的运算符只能作为成员函数重载; ( C)能够为运算符重载函数改变其运算符原有的运算目数; ( D)有的运算符可以作为非成员函数重载。 19 下列关于运算符函数的表述中,错误的是 ( )。 ( A)运算符函数的参数表可能是空的; ( B)运算符函数只能定 义为类的成员函数; ( C)运算符函
6、数的名称是以 operator为前缀的; ( D)运算符函数的参数可以是对象。 20 有如下程序; #include using namespace std; void fun(int&a, _)int c; c-a; a=b; b=c; int main() int x=14, y=20; fun(x, y); cout using namespace std; class Bag public: Bag(int p, char s=M): price(p), size(s) void Show()cout using namespace std; class Equipment publi
7、c: Equipment()cout using namespace std; class Power public: Power(int x): val(x) protected: int val; ; class Square: public Power public: Square(int x): Power(x) void Display()coutDisplay(); delete p; return 0; 若运行时的输出结果为 “3的平方是 9”,则划线处缺失的语句可能是 ( )。 ( A) void Display()l ( B) virtual void Display()=0
8、 ( C) void virtual Display()=O; ( D) void Display()virtual 33 有如下程序: #include #include using namespace std; class MyBag public: MyBag(string br, string or): brand(br), color(or)+count; static int GetCount()return count; private: string brand, color; static int count; ; int MyBag: count=0; int main()
9、 MyBag one(CityLife, Gray); tout using namespace std; class Point public: Point(int xx, int yy): x(xx), y(yy) int Getxy()return x+y; private: int x, y; ; class Circle: public Point public: Circle(int r, int x=0, int y=0): Point(x, y), radius(r) private: int radius; ; int main() Circle a(6, 5, 4), b(
10、4, 3, 2); cout using namespace std; class Point public: Point(int xx=0, int yy=0): x(xx), y(yy) void SetX(int xx)x=xx; void SetY(int yy)y=yy; private: int x, y; ; class Circle: public Point public: Circle(int r): radius(r) int GetRadius()return radius; protected: void SetRadius(int r)radius=r; priva
11、te: int radius; ; int main() Circle c1l(5); c1 SetX(1); c1 SetY(2); c1 SetRadius(6); cout #include using namespace std; class Instrument public: Instrument(string t, string n): type(t), name(n) virtual string GetType()constreturn type; virtual string GetName()constreturn name; protected: string type
12、, name; ; class Piano: public Instrument public: Piano(string n=AB, string t=CD): Instrument(n, t) string GetType()constreturnWX; string GetName()constreturnYZ; ; int main() Instrument*pi=new Piano(); coutGetType()GetName() #include using namespace std; class MP3Player “MP3播放器 ”类 char* type;型号 char*
13、color;颜色 public: ERROR*found* MP3Player(const char* ty=NULL, const char* co) ERROR*found* if(ty=NULL) type=NULL; else type=new charstrlen(ty)+1; strcpy(type, ty); if(co=NULL) color=NULL; else color=new charstrlen(co)+1; strcpy(color, co); MP3Player() if(type)deletetype; ERROR*found* if(color)delete
14、color; const char*getType()constreturn type; const char*getColor()constreturn color; ; int main() MP3Phyer myplayer(“天籁 -1”, “黑色 ”); cout using namespace std; class Room “房间 ”类 int room_no;房间号 double length;房间长度 (m) double width;房间宽度 (m) public: Room(int the_room_no, double the_length, double the_wi
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 模拟 131 答案 解析 DOC
