【计算机类职业资格】国家二级C++机试(操作题)模拟试卷374及答案解析.doc

上传人:roleaisle130 文档编号:1331872 上传时间:2019-10-17 格式:DOC 页数:3 大小:34KB
下载 相关 举报
【计算机类职业资格】国家二级C++机试(操作题)模拟试卷374及答案解析.doc_第1页
第1页 / 共3页
【计算机类职业资格】国家二级C++机试(操作题)模拟试卷374及答案解析.doc_第2页
第2页 / 共3页
【计算机类职业资格】国家二级C++机试(操作题)模拟试卷374及答案解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级 C+机试(操作题)模拟试卷 374及答案解析(总分:6.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:2.00)1.使用 VC6打开考生文件夹下的源程序文件 modi 1cpp,该程序运行时有错误,请补充程序中的丢失部分,使得程序运行。可以在修改处增加或者删除一条语句。本程序完成以下功能: (1)获得输入的两个数字 x1,x2(例如 x1=4,x2=2); (2)输出两个中较小的一个(例如输出 2); (3)计算 x1x2 如果 X2等于0,返回-1(输出结果 2); (4)输出 x1+x2的结果(输出结果 6): (5)输出 x1+1的结果(输出结果 5); (6)

2、输出 x2-1的结果(输出结果 1)。注意:不要改动 main函数,不能增行或删行,也不能更改程序的结构,错误的语句在*error*的下面。#inCludei0StreamhVoid main() int x1; int x2; int X3; cout“please input two number:”end1; Cinx1x2; *error* x3=(x1x2)?x1:x2; cout“Min number is :”x3end1;计算 x1x2 如果 x2等于 0,返回一 1 *error* x3=(x2)?x1x2:一 1; cout“x1x2=”x3end1; *error* x3

3、=(一一 x1)+(x2+); cout“x1+x2= “x3end1; cout“x1+1= “x1end1; cout“x21= “x2end1; return;(分数:2.00)_二、简单应用题(总题数:1,分数:2.00)2.使用 VC6打开考生文件夹下的源程序文件 modi2clap。完成函数 fun(int a口,int n),实现递归函数 fun(hat a,int n)的返回值是数组 a的前 n个元素之和。 注意:不能修改程序的其他部分,只能修改 fun()函数。#includeiostreamhint fun(int a,int n)void main() int A=1,2

4、,3,4); coutfun(A,Sizeof(A)iZeof(int)end1; return; (分数:2.00)_三、综合应用题(总题数:1,分数:2.00)3.使用 VC6打开考生文件夹下的源程序文件 modi3cpp,通过把类 Distance定义为类 Point的友元类,来实现计算两点之间距离的功能。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)把类 CDistance定义为类 CPoint的友元类。请在注释*1*之后添加适当的语句。 (2)定义类 CPoint的构造函数,完成给私有数据成员 x和 y的赋值,并且两个参数的缺省值都为 0。请在注释*2*之后添

5、加适当的语句。 (3)完成类 CDistance的成员函数length(Pointfloat CDistance:length(CPointfloat CDistance:length(CPoint&pPoint,CPoint&qPoint) *3*int main() CPoint mPoint(10,10),nPoint(40,50); mPointdisplay(); nPointdisplay(); CDistance len; coutlen1ength(mPoint,nPoint)endl; return 0;(分数:2.00)_正确答案:(正确答案:(1)添加语句:friend clasS CDiStance; (2)添加语句:CPoint(float a=0,float b:0)x=a;y=b;) (3)添加语句:return sqrt(pPointxqPointX)*(pPointxqPointX)+(pPointyqPointy)*(pPointyqPointy);)解析:解析:程序当中定义了类 CPoint和 CDistance,CPoint 类含有成员变量 x和 y,display()函数输出 x和 y的值;类 CDistance只有成员函数 length(CPoint&p,CPoint&q),且类 CDistance为类 CPoint的友元类。

展开阅读全文
相关资源
猜你喜欢
  • ASTM D7645-2014 7320 Standard Test Method for Determination of Aldicarb Aldicarb Sulfone Aldicarb Sulfoxide Carbofuran Methomyl Oxamyl and Thiofanox in Water by Liquid Chromatograp.pdf ASTM D7645-2014 7320 Standard Test Method for Determination of Aldicarb Aldicarb Sulfone Aldicarb Sulfoxide Carbofuran Methomyl Oxamyl and Thiofanox in Water by Liquid Chromatograp.pdf
  • ASTM D7645-2016 red 5465 Standard Test Method for Determination of Aldicarb Aldicarb Sulfone Aldicarb Sulfoxide Carbofuran Methomyl Oxamyl and Thiofanox in Water by Liquid Chromato.pdf ASTM D7645-2016 red 5465 Standard Test Method for Determination of Aldicarb Aldicarb Sulfone Aldicarb Sulfoxide Carbofuran Methomyl Oxamyl and Thiofanox in Water by Liquid Chromato.pdf
  • ASTM D7646-2010 0625 Standard Test Method for Determination of Cooling Characteristics of Aqueous Polymer Quenchants for Aluminum Alloys by Cooling Curve Analysis《冷却曲线分析法测定铝合金用水性聚合.pdf ASTM D7646-2010 0625 Standard Test Method for Determination of Cooling Characteristics of Aqueous Polymer Quenchants for Aluminum Alloys by Cooling Curve Analysis《冷却曲线分析法测定铝合金用水性聚合.pdf
  • ASTM D7646-2010(2014) 7947 Standard Test Method for Determination of Cooling Characteristics of Aqueous Polymer Quenchants for Aluminum Alloys by Cooling Curve Analysis《采用冷却曲线分析法测定.pdf ASTM D7646-2010(2014) 7947 Standard Test Method for Determination of Cooling Characteristics of Aqueous Polymer Quenchants for Aluminum Alloys by Cooling Curve Analysis《采用冷却曲线分析法测定.pdf
  • ASTM D7647-2010 1250 Standard Test Method for Automatic Particle Counting of Lubricating and Hydraulic Fluids Using Dilution Techniques to Eliminate the Contribution of Water and I.pdf ASTM D7647-2010 1250 Standard Test Method for Automatic Particle Counting of Lubricating and Hydraulic Fluids Using Dilution Techniques to Eliminate the Contribution of Water and I.pdf
  • ASTM D7647-2010(2018) 6875 Standard Test Method for Automatic Particle Counting of Lubricating and Hydraulic Fluids Using Dilution Techniques to Eliminate the Contribution of Water.pdf ASTM D7647-2010(2018) 6875 Standard Test Method for Automatic Particle Counting of Lubricating and Hydraulic Fluids Using Dilution Techniques to Eliminate the Contribution of Water.pdf
  • ASTM D7648-2012 5000 Standard Practice for Active Soil Gas Sampling for Direct Push or Manual-Driven Hand-Sampling Equipment《直接推动或手动驱动的人工取样设备对活性土壤气体取样的标准操作规程》.pdf ASTM D7648-2012 5000 Standard Practice for Active Soil Gas Sampling for Direct Push or Manual-Driven Hand-Sampling Equipment《直接推动或手动驱动的人工取样设备对活性土壤气体取样的标准操作规程》.pdf
  • ASTM D7649-2010 2500 Standard Test Method for Determination of Trace Carbon Dioxide Argon Nitrogen Oxygen and Water in Hydrogen Fuel by Jet Pulse Injection and Gas Chromatography M.pdf ASTM D7649-2010 2500 Standard Test Method for Determination of Trace Carbon Dioxide Argon Nitrogen Oxygen and Water in Hydrogen Fuel by Jet Pulse Injection and Gas Chromatography M.pdf
  • ASTM D7649-2010(2017) 8459 Standard Test Method for Determination of Trace Carbon Dioxide Argon Nitrogen Oxygen and Water in Hydrogen Fuel by Jet Pulse Injection and Gas Chromatogr.pdf ASTM D7649-2010(2017) 8459 Standard Test Method for Determination of Trace Carbon Dioxide Argon Nitrogen Oxygen and Water in Hydrogen Fuel by Jet Pulse Injection and Gas Chromatogr.pdf
  • 相关搜索

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

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