[计算机类试卷]国家二级C++机试(操作题)模拟试卷122及答案与解析.doc
《[计算机类试卷]国家二级C++机试(操作题)模拟试卷122及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级C++机试(操作题)模拟试卷122及答案与解析.doc(8页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级 C+机试(操作题)模拟试卷 122及答案与解析 一、基本操作题 1 请使用 VC6或使用【答题】菜单打开考生文件夹 projl下的工程 projl,此工程中含有一个源程序文件 projl cpp。其中位于每个注释 “ ERROR*found*”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: Constructor called The value is 10 Max number is 20 Destructor called 注意:只能修改注释 “ ERROR*found*”的下一行语句,不要改动程序中的其他内容。 projl cpp #include using n
2、amespace std; class MyClass public: ERROR*found* void MyClass(int i) value=i; couty?x: y; )求两个整数的最 大值 ERROR*found* int Max(int x, int y, int z=0) 求三个整数的最大值 if(xy) return xz?X: z; else return yz?y: z; int GetValue()constreturn value; ) 一 MyClass()cout using namespace std; const int Size=5; class Stac
3、k; class Item f public: * found* Item(const int&val): _) 构造函数对 item进行初始化 private: int item; Item*next; friend clasS Stack; ; class Stack public: Stack(): top(NULL) 一 Stack(); int Pop(); void Push(const int&); private: Item*top; ; Stack:一 Stack() Item*P=top, *q; while(p!=NULL) q=p一 next; *found* _; 释
4、放 P所指向的节点 P=q; int Stack: Pop() Item*temp; int ret; * found* ; 使 temp指向栈顶节点 ret=top一 item; top=top一 next; delete temp; return ret; ) void Stack: Push(const int&val) Item*temp=new Item(val); * found* ; 使新节点的 next指针指向栈顶数据 top=temp; int main() Stack s; for(int i=1; i using namespace std; class MyPoint表
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 机试 操作 模拟 122 答案 解析 DOC
