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

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

1、国家二级 C+机试(操作题)模拟试卷 119及答案与解析 一、基本操作题 1 使用 VC6打开考生文件夹下的源程序文件 modil cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: This is a greart! Hello Hello 注意:错误的语句在 *error*的下面,修改该语句即可。 #include class CNyCIass public: void display1() tout; #include #include us ing namespace std; void WriteFi le(Char*str) ofstream outl; outl

2、 open(”modi2 txt”, los base: binary l losbase: app); for(int i=0 ; stri!=0 ; i+) OUtl put(stri); outl close(); void fun(int X) void ClearFile() ofstream outl ; outl open(”modi2 txt”); outl Close(); int main() ClearFile(); fun(13); return 0 ; 三、综合应用题 3 使用 VC6打开考生文件夹下的源程序文件 modi3 cpp,通过把类 Distance定义为类

3、 Point的友元类,来实现计算两点之间距离的功能。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)把类 CDistance定义为类 CPoint的友元类。请在注释 *1*之后添加适当的语句。 (2)定义类 CPoint的 构造函数,完成给私有数据成员 X和 Y的赋值,并且两个参数的缺省值都为 0。请在注释 *2*之后添加适当的语句。 (3)完成类 CDistance的成员函数 length(Point&pPoint, Point&qPoint)的定义,并在其中计算点 P、 q之间的距离,并且返回结果。假设两点之间的距离distance=sqrt(pPoint xqPoi

4、nt x)*(pPoint X-qPoint x)+(pPoint y-qPoint y)*(pPoint yqPoint y)。请在注释 *3*之后添加适当的语句。 注意:增加代码,或者修改代码的位置已经用符号表示 出来。请不要修改其他的程序代码。 #inc lude #incl ude using namespace std; Class CPoint publ ic: *1* 定义类 Point的构造函数 *2* void displ ay() COil t=0; i一一 )计算二进制 if(x 2)stri=1; 求余,如果余不为零字符串 str第 i位为 1 else stri=0;

5、 否则为 0 X=1; if(!x)break; str3 1= 0; 串加尾符 cout: ,故第 1个标识下应添加 “friend class CDistance; ”O (2)类 CPoint的构造函数完成给私有数据成员 X和 Y的初始化,两个参数的缺省值都为 0,凶此参数含有默认值 0,故第 2个标识下应添加 “CPoint(float a=0,floatb=0)x=a; y=b; ”0 (3)类 CDistance的成员函数 length(CPoint&pPoint, CPoint&qPointl返回点 P、 q之间的距离,可由公式 distance=sqrt(pPoint z-qPoint x)木 (pPoint X-qPoint X)+(pPoint Y qPoint y)*(pPoint y qPoint y)计算求得,第 3个标识下应添加 “return sqrt(pPoint xqPoint x)*(pPoint xqPoint x)+(pPoint YqPoint y)*(pPoint Y-qPoint y); ”0

展开阅读全文
相关资源
猜你喜欢
  • ASD-STAN PREN 4416-2005 Aerospace Series Non-Metallic Materials Textiles Wide Woven Fabrics Technical Specification (Edition P 1)《航空航天系列 非金属材料 纺织品 宽机织织物 技术规范 第P1版》.pdf ASD-STAN PREN 4416-2005 Aerospace Series Non-Metallic Materials Textiles Wide Woven Fabrics Technical Specification (Edition P 1)《航空航天系列 非金属材料 纺织品 宽机织织物 技术规范 第P1版》.pdf
  • ASD-STAN PREN 4419-1997 Aerospace Series Washers Chamfered with Counterbore in Alloy Steel Cadmium Plated (Edition P 1)《航空航天系列 镀镉合金钢制带沉孔的倒角垫圈 第P1版》.pdf ASD-STAN PREN 4419-1997 Aerospace Series Washers Chamfered with Counterbore in Alloy Steel Cadmium Plated (Edition P 1)《航空航天系列 镀镉合金钢制带沉孔的倒角垫圈 第P1版》.pdf
  • ASD-STAN PREN 4420-1999 Aerospace Series Clips Spring Tension in Alloy Steel FE-PA3903 (Edition P 1)《航空航天系列 FE-PA3903合金钢制拉伸弹簧卡箍 第P1版》.pdf ASD-STAN PREN 4420-1999 Aerospace Series Clips Spring Tension in Alloy Steel FE-PA3903 (Edition P 1)《航空航天系列 FE-PA3903合金钢制拉伸弹簧卡箍 第P1版》.pdf
  • ASD-STAN PREN 4421-2000 Aerospace Series Studs in Titanium Alloy TI-P64001 MoS2 Coated with Serrated Locking Ring in Corrosion Resisting Steel Strength Class 1 100 MPa (at Ambient .pdf ASD-STAN PREN 4421-2000 Aerospace Series Studs in Titanium Alloy TI-P64001 MoS2 Coated with Serrated Locking Ring in Corrosion Resisting Steel Strength Class 1 100 MPa (at Ambient .pdf
  • ASD-STAN PREN 4424-1998 Aerospace Series Rod-Ends Adjustable Single Fork and Threaded Shank with Engagement 1 5 x Thread Diameter in Titanium Alloys Dimensions and Loads (Edition P.pdf ASD-STAN PREN 4424-1998 Aerospace Series Rod-Ends Adjustable Single Fork and Threaded Shank with Engagement 1 5 x Thread Diameter in Titanium Alloys Dimensions and Loads (Edition P.pdf
  • ASD-STAN PREN 4425-1998 Aerospace Series Washers Tab in Corrosion Resisting Steel for Flight Control Rods Dimensions (Edition P 1)《航空航天系列 飞行操纵杆用耐蚀钢制止动垫圈 尺寸 第P1版》.pdf ASD-STAN PREN 4425-1998 Aerospace Series Washers Tab in Corrosion Resisting Steel for Flight Control Rods Dimensions (Edition P 1)《航空航天系列 飞行操纵杆用耐蚀钢制止动垫圈 尺寸 第P1版》.pdf
  • ASD-STAN PREN 4426-2001 Aerospace Series Non-Metallic Materials Textiles Test Method Determination of Conductivity and pH of Aqueous Extracts (Edition P 1)《航空航天系列 非金属材料 纺织品试验方法 水性提.pdf ASD-STAN PREN 4426-2001 Aerospace Series Non-Metallic Materials Textiles Test Method Determination of Conductivity and pH of Aqueous Extracts (Edition P 1)《航空航天系列 非金属材料 纺织品试验方法 水性提.pdf
  • ASD-STAN PREN 4429-2005 Aerospace series Non-metallic materials Textiles Testing of narrow woven fabrics Determination of warp bow (Editon P 1)《航空航天系列 非金属材料 纺织品 窄机织织物的试验 弯曲度测定 第P1版.pdf ASD-STAN PREN 4429-2005 Aerospace series Non-metallic materials Textiles Testing of narrow woven fabrics Determination of warp bow (Editon P 1)《航空航天系列 非金属材料 纺织品 窄机织织物的试验 弯曲度测定 第P1版.pdf
  • ASD-STAN PREN 4434-2003 Aerospace Series Copper or Copper Alloy Lightweight Conductors for Electrical Cables Product Standard (Normal and tight tolerances) (Edition P 2)《航空航天系列 电缆用.pdf ASD-STAN PREN 4434-2003 Aerospace Series Copper or Copper Alloy Lightweight Conductors for Electrical Cables Product Standard (Normal and tight tolerances) (Edition P 2)《航空航天系列 电缆用.pdf
  • 相关搜索

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

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