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

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

1、国家二级 C+机试(操作题)模拟试卷 455及答案与解析 一、基本操作题 1 请使用 VC6或使用【答题】菜单打开考生文件夹 proj1下的工程 proj1。程序中位于每个 “ ERROR*found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: value=63 number=1 注意:只修改每个 “ ERROR*found*”下的那一行,不要改动程序中的其他内容。 #include using namespace std; class MyClass int*p; const int N; public: ERROR *found* MyClass(int val): N

2、1 p=new int; *p=val; ERROR*found* MyClass()delete*p; ) friend void print(MyClass&obj); ; ERROR*found* void MyClass: print (MyClass&obj) cout using namespace std; class Sale public: Sale();默认构造函数,将 price初始化为 0 Sale(double the_price); 构造函数,用 the_price初始化 price virtual double bill() const;返回当前商品的价格 (基

3、本价 ) double savings(const Sale&other)const;返回参数 other所引用的对象比当前对象便宜的差价 protected: double price;商品的基本价格 (不打折的价格 ) ; Sale: Sale(): price(0) Sale: Sale(double the price): price(the price) double Sale: bill()const return price; double Sale: savings(const Sale&other)const ERROR*found* _;返回当前对象价格比 other贵多少

4、的差价 class DiscountSale: public Sale打折销售类继承销售类 public: DiscountSale();默认构造函数,将 discount初始化为 0 DiscountSale(double the_price, double the discount);构造函数, the_price是基本价格; the discount是折扣百分比 virtual double bill()const;返回本商品销售价格 (即打折以后的实际售价,覆盖了基类的 bill函数 ) protected: double discount;折扣百分比。例如降价至原价的 70,此成员值

5、应为 70 ; DiscountSale: DiscountSale(): discount (0) DiscountSale: DiscountSale (double the price, double the discount) : Sale(the price), discount (the discount) double DiscountSale: bill () const double fraction=discount 100; *found* _;返回本对象打折以后的实际售价 bool operatorbill()-other bill() (2)return fracti

6、on*price (3)return first bill()bill()-other bill() 同样, this指针引用当前对象, other是引用对象,所以可以与 bill()虚函数一起使用多态机制,获 得当前对象和 other对象的实际价格,再进行差值计算 (4)main()函数中,程序判断 discount小于 sire-ple后,输出提示信息,再调用savings()函数输出 discount和 simple的差值,这里需要计算 discount比 simple节省多少钱,所以需要将 simple当做当前对象, discount当做参数传人 savings()函数,所以补充语句如

7、下: simple savings(discount) 三、综合应用题 3 【正确答案】 1f(1ncomelower_limitsi) 如果 taxable(收入超出起征额的部分 )大于 lower limitsi阶段最低限额 tax payable += (taxable-lower_limitsi)*ratesi; 把起过阶段最低限额的部分乘以该阶段的税率后,加到 tax_payable(个人所得税 ) taxable=lower_limitsi; 把 fower limitsi赋值于 taxable 【试题解析】 主要考查考生对成员函数的掌握情况,根据题目要求可知,完成计算应纳个人所得税额的成员函数 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