[计算机类试卷]国家二级(C++)机试模拟试卷107及答案与解析.doc
《[计算机类试卷]国家二级(C++)机试模拟试卷107及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级(C++)机试模拟试卷107及答案与解析.doc(31页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级( C+)机试模拟试卷 107及答案与解析 一、选择题 1 在软件开发中,需求分析阶段可以使用的工具是 ( )。 ( A) N S图 ( B) DFD图 ( C) PAD图 ( D)程序流程图 2 有如下函数定义: void func(int a, int b+; 若执行代码段: int x = 0, y = 1; func(x, y); 则变量 x和 y的值分别是 ( )。 ( A) 0和 1 ( B) 1和 1 ( C) 0和 2 ( D) 1和 2 3 下列代码段中声明了 3个类: class Person ; class Student : public Person ; cl
2、ass Undergraduate : Student ; 下列关于这些类之间关系的描述中,错误的是 ( )。 ( A)类 Person是类 Undergraduate的基类 ( B)类 Undergraduate 从类 Student公有继承 ( C)类 Student是类 Person的派生类 ( D)类 Undergraduate是类 Person的派生类 4 数据库系统的三级模式不包括 ( )。 ( A)概念模式 ( B)内模式 ( C)外模式 ( D)数据模式 5 计算数列第 n 项的函数定义如下: int a(int n) if (n = 0) return 0; else if
3、(n = 1) return 1; else if (n = 2) return 2; else return a(n-1)+a(n-3); 若执行函数调用表达式 a(4),函数 a 被调用的次数是 ( A) 3 ( B) 4 ( C) 5 ( D) 6 6 有如下程序: #include #include using namespace std; class Instrument public: Instrument(string t=“乐器 “,string n=“无名 “):type(t),name(n) virtual string GetType() const return “乐器
4、 “; string GetName() const return “无名 “; protected: string type,name; ; class Piano:public Instrument public: Piano(string n,string t=“钢琴 “):Instrument(t,n) string GetType() const return “钢琴 “; string GetName() const return name; ; int main() Instrument *pi=new Piano(“星空 “); coutGetType()GetName();
5、delete pi; return 0; 运行时的输出结果是 ( A)乐器 -星空 ( B)乐器 -无名 ( C)钢琴 -星空 ( D)钢琴 -无名 7 ( A)自然连接 ( B)交 ( C)投影 ( D)并 8 有如下程序: #include using namespace std; class XA int a; public: static int b; XA(int aa):a(aa) b+; XA() int get() return a; ; int XA:b=0; int main() XA d1(2),d2(3); coutvoidswap(Ta,Tb,intsize); (
6、B) templatevoidswap(intsize,Ta,Tb); ( C) templatevoidswap(T1a,T2b,intsize); ( D) templatevoidswap(T1a,T2b,intsize); 10 有如下程序: #include using namespace std; int main() int sum = 0; for(int i = 0; i double 由此可知 ( )。 ( A)这可能是一个函数模板的声明 ( B)这可能是一个类模板的声明 ( C)这既可能是一个函数模板的声明,也可能是一个类模板的声明 ( D)这肯定是一个错误的模板声明 2
7、3 下列关于 return语句的叙述中,正确的是 ( A)任何函数的函数体中至少有一个 return语句 ( B)任何函数的函数体中最后一条语句必须是 return语句 ( C)如果函数的返回类型为 void,则其函数体中可以没有 return语句 ( D)如果函数的返回类型为 int,则其函数体中可以没有 return语句 24 有如下程序: #include #include using namespace std; class MyBag public: MyBag(string br=“ABC“):brand(br) coutvoidswap(Ta,Tb,intsize); ( B)
8、templatevoidswap(intsize,Ta,Tb); ( C) templatevoidswap(T1a,T2b,intsize); ( D) templatevoidswap(T1a,T2b,intsize); 28 有如下程序段: int i=0; while(1) i+; if(i = 30) break; if(i/20 = 0) 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
9、) y=yy; private: int x,y; ; class Circle:Point public: Circle(int r):radius(r) int GetRadius() return radius; private: void SetRadius(int r) radius=r; int radius; ; int main() Circle c1(5); c1.SetX(1); / c1.SetY(2); / c1.SetRadius(10); / cout #include using namespace std; class MyBag public: friend
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 模拟 107 答案 解析 DOC
