[计算机类试卷]国家二级C++机试(操作题)模拟试卷361及答案与解析.doc

上传人:outsidejudge265 文档编号:497445 上传时间:2018-11-28 格式:DOC 页数:7 大小:32.50KB
下载 相关 举报
[计算机类试卷]国家二级C++机试(操作题)模拟试卷361及答案与解析.doc_第1页
第1页 / 共7页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷361及答案与解析.doc_第2页
第2页 / 共7页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷361及答案与解析.doc_第3页
第3页 / 共7页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷361及答案与解析.doc_第4页
第4页 / 共7页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷361及答案与解析.doc_第5页
第5页 / 共7页
点击查看更多>>
资源描述

1、国家二级 C+机试(操作题)模拟试卷 361及答案与解析 一、基本操作题 1 使用 VC6打开考生文件夹下的源程序文件 modil cpp,该程序运行时有错误,请改正程序中的错误,使得程序运行后没有内存遗漏。可以在修改处增加或者删除一条语句。本程序完成输入两个字符串,分别存储到 s1, s2中。 注意:不要改动 main函数,不能增行或删行,也不能更改程序的结构,错误的语句在 *error*的下面。 #include Void main() char*s1; char s2102 4; cout class NODE public: int data; NODE*nexl; ; void fu

2、n(NODE*list, int x) void main() int x; NODE*head, *P; *首先建立只有辅助表元的空链表 * head=new NODE; head-next=NULL; std: couLx; if( x=0) break; fun(head, x); for(P=head一 next; P!=NULL; p=p一 next) std: coutdatanext; delere head; head=P; while(P); 三、综合应用题 3 使用 VC6打开考生文件夹下的源程序文件 modi3 cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义

3、补充完整。完成以下功能: (1)完成构造函数,设置数组元素的个数为 0,请在注释 *1*之后添加语句。 (2)完成函数 AddMember(int n),如果参数 n包含在类的数据成员数组中,则返回0,否则把数据写入数组,然后返回 1,请在注释 *2*之后添加语句。 (3)完成函数 DelMember(int n),如果变量在数据中,则删除该变量,并且返回1,如果不存在则返回 0,请在注释 *3*之后添加语句。 (4)完成成员函数 isInclude(int n)的定义,该函数检查参数 n是否在类的数据成员数组 elems中,如果在返回 1,否则返回 0。请在注释 *4*之后添加语句。 注意:

4、除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include #define MAX LENGTH 500 clas s CArray public: CArray() *1* int AddMember(int n) for(int i=0; inext; while(v!=NULL Xdata) 寻找插入的位置 u=v; v=v-next; if(v=NULL Xv一 data) 判断是否为新的元素 p=new NODE; P一 data=x; 生成新的元素 P一 next=v: u-next=p; 插入新的元素 【试题解析】 (1)该程序功能是构造一个以大到小顺序链接的链表。

5、它的解题思路,首先寻找插入 的位置,然后判断是否为新元素,最后插入。 (2)从己给部分源程序的 main主函数开始入手核心函数 void fun(NODE*list, int x)中的 list参数为单链表, x为要插入的数据。 三、综合应用题 3 【正确答案】 (1)添加语句: length=0; (2)将 “if(Arrayi=n)”补充完整为: if(Arrayi=n)或 if(n=: Arrayi) (3)将 “if()”补充完整为: if(ilength)或 if(i!=length) (4)将 “i f()”补充完整为: if(Arrayi=n)或 if(n=Arrayi) 【试题解析】 程序中定义了类 CArray,有两个数据成员和多个成员函数。变量为 length用来记录数组元素的个数,数组 ArrayMAX LENGTH用来存放数组元素。成员函数 AddMember0和 DelMember()分别表示添加和删除元素,函数islnclude(int n)检查数组当中是否存在值为 n的元素。

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf
  • BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1