[计算机类试卷]国家二级(C++)机试模拟试卷119及答案与解析.doc
《[计算机类试卷]国家二级(C++)机试模拟试卷119及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级(C++)机试模拟试卷119及答案与解析.doc(33页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级( C+)机试模拟试卷 119及答案与解析 一、选择题 1 关于函数声明格式中的 ,下列叙述错误的是 ( A) 有可能包含关键字 true ( B) 有可能包含自定义标识符 ( C) 有可能包含字符 * ( D) 有可能包含关键字 float 2 下列关于运算符重载的叙述中,错误的是 ( A)不能通过运算符重载在 C+ 中创建新的运算符 ( B)赋值运算符只能重载为成员函数 ( C)运算符函数重载为类的成员函数时,第一操作数是该类对象 ( D)重载类型转换运算符时,应声明返回类型为 void 3 下列运算符中,不能被重载的是 ( A) | ( B) += ( C) . ( D) - 4
2、 下列叙述中正确的足 ( )。 ( A)循环队列是顺序存储结构 ( B)循环队列是链式存储结构 ( C)循环队列是非线性结构 ( D)循环队列的插入运算不会发生溢出现象 5 下列叙述中正确的是 ( )。 ( A)所有数据结构必须有根结点 ( B)所有数据结构必须有终端结点 (即叶子结点 ) ( C)只有一个根结点,且只有一个叶子结点的数据结构一定是线 性结构 ( D)没有根结点或没有叶子结点的数据结构一定是非线性结构 6 下列关于算法的描述中错误的是 ( ) ( A)算法强调动态的执行过程,不同于静态的计算公式 ( B)算法必须能在有限个步骤之后终止 ( C)算法设计必须考虑算法的复杂度 (
3、D)算法的优劣取决于运行算法程序的环境 7 在线性表的顺序存储结构中,其存储空间连续,各个元素所占的字节数 ( )。 ( A)相同,元素的存储顺序与逻辑顺序一致 ( B)相同,但其元素的存储顺序可以与逻辑顺序不一致 ( C)不同,但元素的存储顺序与逻 辑顺序一致 ( D)不同,且其元素的存储顺序可以与逻辑顺序不一致 8 设二叉树如下: 则中序序列为 ( )。 ( A) ABDEGCFH ( B) DBGEAFHC ( C) DGEBHFCA ( D) ABCDEFGH 9 下面不属于软件需求分析阶段工作的是 ( )。 ( A)需求获取 ( B)需求计划 ( C)需求分析 ( D)需求评审 10
4、 下面不属于黑盒测试方法的是 ( )。 ( A)边界值分析法 ( B)基本路径测试 ( C)等价类划分法 ( D)错误推测法 11 在数据库系统中,数 据模型包括概念模型、逻辑模型和 ( )。 ( A)物理模型 ( B)空间模型 ( C)时间模型 ( D)数据模型 12 若实体 A和 B是一对一的联系,实体 B和 c是多对一的联系,财实体 A和 c的联系是 ( )。 ( A)多对一 ( B)一对多 ( C)一对一 ( D)多对多 13 某二叉树中共有 935个结点,其中叶子结点有 435个,则该二叉树中度为 2的结点个数为 ( )。 ( A) 64 ( B) 66 ( C) 436 ( D)
5、434 14 下列描述中,属于面向对象思想主要特征的是 ( )。 ( A)继承性 ( B)灵活性 ( C)可重用性 ( D)健壮性 15 有如下程序段: int i=10; while(1) i+: if(i=30)13reak; if(i 2=0)cout using namespace std; void fun(int&a, _) int c; c=a; a=b; b=c; int main() int x, y; x=1; y=2; fun(x, y); eout using namespaee std; class AA public: AA()eout using namespae
6、e std; class Shape图形类 public: 图形绘制函数 (用显示字母模拟 ) virtual void draw()eonsttoutdraw(); int main() Shape s; Triangle t; plot(&s); plot(&t); s=t: s draw(); return 0; 运 行这个程序的输出是 ( )。 ( A) STT ( B) STS ( C) TSS ( D) TTT 41 有如下的类声明: #include using namespace std; class AA public: virtual void disp()eout usi
7、ng namespace std; class Door int num;门号 bool dosed; true表示门关着 bool locked; true表示门锁着 public: Door(int num) ERROR*found* nm=this-Rum; closed=locked=true; bool isClosed()eonstreturn dosed; 门关着时返回 true,否则返回 false bool isOpened()eonstlreturn!closed; 门开着时返回 true,否则返回 false bool isLoeked()eonstreturn lock
8、ed; 门锁着时返回 true,否则返回 false bool islJnlocked()eonstretllm!locked; 门未锁时返回 true,否则返回 false void open() 开门 eout using namespace std; class Time private: int hour; int minute; int second; public: Time(int h, int m, int S) this-hour=h: this-minute=m: this-second=s; bool operator(Time&fight)const if(this-h
9、ourright hour | (this_hour=right hour&this_minuteright minute)| (this-hour=right hour&this-minute=right minute&this-secondright second) *found* _; return false; ; class StreetLight private: int id: bool is_on; Time current_time; public: StreetLight(int id, int hour, int minute, int second) *found* :
10、 _ this-is_on=false: this-id=id: void turn-on() this-is_on=true; coutidis_on) return false; if(current_timetime_threshold) return true; *found* retum_; int main() StreetLight* lightl=new StreetLight(1, 17, 34, 45); StreetLight*light2=new StreetLight(2, 18, 34, 45); Time time_threshold(18, 0, 0); if(
11、1ightl-check(time_threshold) lightl-turn_on(); if(1ight2-check(time_threshold) light2-turn_on(); return 0; 四、综合应用题 46 请使用 VC6或使用 答题 菜单打开考生文件夹 proj3下的工程 proj3,其中声明的 DataList类,是一个用于表示数据表的类。 sort成员函数的功能是将当前数据表中的元素升序排列。请编写这个 sort函数。程序的正确输出应为: 排序前: 7, 1, 3, 1 1, 6, 9, 12, 10, 8, 4, 5, 2 排序后: 1, 2, 3, 4,
12、5, 6, 7, 8, 9, 10, 1 1, 12 要求: 补充编制的内容写在 “ *333*”与“*666*”两行之间。不得修改程序的其他部分。 注意:程序最后将结果输出到文件 out dat中。输出函数 writeToFile已经编译为 obj文件,并且在本程序调用。 DataList h #include using namespaee std; class DataList数据表类 mt len double * d; public: DataList(int len, double data=NULL); DataList()deleted; int length()eonstre
13、tum len; 数据表长度 (即数据元素的个数 ) double getElement(int i)eonstreturn di; void sort();数据表排序 void show()eonst;显示数据表 ; void writeToFie(char*, eonst DataList&); main epp #include“DataList h“ DataList: DataList(int len, double data): len(1en) d=new double1en; for(int i=0; ilen; i+) di=(data=NULL?0 0: datai); v
14、oid DataList: sort()数据表排序 *333* *666* void DataList: show()eonst显示数据表 for(int i=0; ilen-1; i+)eoutdi“, “; eoutdlen-1endl; int main() double s=7, 1, 3, 11, 6, 9, 12, 10, 8, 4, 5, 2; DataList list(12, s); eout“排序前: “; list show(); list sort(); eoutendl“排序后: “; list show(); writeToFile(“, list); return
15、 0; 国家二级( C+)机试模拟试卷 119答案与解析 一、选择题 1 【正确答案】 C 【试题解析】 本题考查函数返回类型,函数返回类 型可以是普通常量型的,可以返回指针以及自定义类型,但是不能包含关键字 true,所以 A选项错误。 2 【正确答案】 A 【试题解析】 本题考查运算符重载,重载不能定义新的运算符,且赋值运算符只能重载为成员函数,重载类型转换运算符时,声明返回类型不一定是 void,所以D选项错误。 3 【正确答案】 D 【试题解析】 本题考查运算符重载,不能重载的运算符只有 5个: .、 .*、 :、sizeof、 ?: 所以本题选择 C 4 【正确答案】 A 【试题解析
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 模拟 119 答案 解析 DOC
