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

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

1、国家二级 C+机试(操作题)模拟试卷 142及答案与解析 一、基本操作题 1 请使用 VC6或使用【答题】菜单打开考生文件夹 progl下的工程 progl,该工程中包含程序文件 main cpp,其中有 Salary(“工资 ”)类和主函数 main的定义。程序中位于每个 “ ERROR *found*”之后的一行语句行有错误,请加以改正。改正后程序的输出结果应为: 应发合计: 3500应扣合计: 67 5实发工资 3432 5 注意:只修改每个 “ ERROR*found*”下的那一行,不要 改动程序中的其他内容。 #include using namespace std; class S

2、alary public: Salary(const char*id, double thebase, double thebonus, double thetax) ERROR*found* : the base(base), the bonus(bo nus), the tax(tax) staff id=new char strlen(id)+1; strcpy(staff_id, id); ERROR*found* Salary()delete*staffid; ) double getGros s Pay()constreturn base+bonus; 返回应发项合计 double

3、 getNetPay()constreturn get GrossPay()一 tax; )返回实发工资额 private: char*staff id; 职工号 double base; 基本工资 double bonus; 奖金 double tax; 代扣个人所得税 ; int main() Salary pay(“888888”, 3000 0, 500 0, 67 50); cout using namespace std; class Department “部门 ”类 public: Department (const char * name, const char*office

4、) strcpy(this一 name, name); *found* const char*getName()constreturn name; ) 返回部门名称 *found* const char*getOffice()const_) 返回办公室房号 void changeOfficeT0(const char*office) 改换为指定房号的另一个办公室 strcpy(this一 office, office); private: char name2 0; 部门名称 char office20;部门所在办公室房号 ; class Staff “职工 ”类 public: *found

5、 Staff(const char*myid, const char*myname, Department&mydept): _ strcpy(this一 staff_id, my id); strcpy(this一 name, my_name); const char*getID()constreturn staff id; ) const char*getName()constreturn name; Department getDepartment()const return dept; private: char staff id10; 职工号 char name20; 姓名 Dep

6、artment&dept; 所柱部门 ; void showStaff(Staff staff) coutoffice, office); (2)return office; (3)dept(mydept) (4)dept changeOfficeTo(”311”); 【试题解析】 本题考查的是 Department类和 Staff类,其中涉及构造函数、strcpy()函数和 const函数。复制字符串使用函数 strcpy,构造函数的成员列表初始化时不能初始化指针。 【解题思路】 (1)主要考查考生对 strcpy函数的掌握情况,根据上一条语句: strcpy(this一 name, nam

7、e);可知,这条语句复制的 是 office,即 strcpy(this一 office,office);。 (2)主要考查考生对成员函数的掌握情况,根据语句的注释:返回办公室房号可知,要填写的是一条 return语句。在私有成员里: char office20;部门所在办公室房号,表明 office即为办公室房号。因此直接返回 office即可。 (3)主要考查考生对构造函数的掌握情况,根据函数体: strepy(this一 staff_id, my_id); strepy(this一 name, my_name); 可知,只有 dept没有初始化,而空格前有字符 “: ”,这是成员列表初始

8、化的标识符,因此填写 dept(mydept)即可。 (4)主要考查考生对成员函数的调用的掌握情况,根据题目要求:人事处办公室由521搬到 311。在 Department类中有函数 void changeOfficeTo(const char*office)可以修改办公室的房间号,直接调用即可。 【解题宝典】 主要考查考生对 strcpy()函数及构造函数的掌握情况, strepy(参数一,参数二 )函数的功能是复制参数二的字符串给参数一。 三、综合应用题 3 【正确答案】 if(1ncomelower limits i) 如果 taxable(收入超出起征额的部分 )大于 lower li

9、mitsi阶段最低限额 taxpayable += (taxable lower limitsi)*ratesi; 把起过阶段最低限额的部分乘以该阶段的税率后 ,加到 taxpayable(个人所得税 ) taxable : lowerlimitsi; 把 fower limitsi赋值于 taxable 【试题解析】 本题考查的是 TaxCalculator类,其中涉及构造函数、析构函数和动态数组。 TaxCalculator类是个税计算器,首先要明白如何计算税率,然后结合类中的成员完成函数。 【解题思路】 主要考查考生对成员函数的掌握情况,根据题目要求可知,完成计算应纳个人所得税额的成员函数 getTaxPayable,其中参数 income为月收入。同时题目 还表明:不超过 2000元的所得不征收个人所得税。因此先用 if语句判断是否要征收个人所得税。然后根据题目所给表格,来判断收入多少及应该收多少个人所得税。 【解题宝典】 主要考查考生对成员函数的掌握,程序和生活息息相关,关于这类程序考生仔细琢磨题目。

展开阅读全文
相关资源
猜你喜欢
  • 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