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

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

1、国家二级 C+机试(操作题)模拟试卷 385及答案与解析 一、基本操作题 1 使用 VC6打开考生文件夹下的源程序文件 modil cpp,该程序运行时有错,请改正其中的错误,使得程序正常运行,并使程序输出的结果为: sizeof(str1)=5 sizeof(str2)=10 sizeof(str3)=1 注意:不要改动 main函数,不能增行或删行,也不能更改程序的结构, 错误的语句在 *error*的下面。 (1)不能删除 assert()语句: (2)只能修改后面的数字。 提示: assert()函数如果为假,则会产生一个中断异常。 #include #include void mai

2、n() char*str1=“abc”; *error* assert(sizeof(Str1)=3); cout #define MAXNLEN 100 void factor(int*des, int&length, int n) void main() int aMAXNLEN, length; int n=2 0; factor(a, length, n); for(int i=0; i Class TeStClass public: *1* TestClass(int i, int j) m Numl=i; m Num3+=i; void Print() cout“m Num1=”m

3、 Numlendl; cout“m Num2=”m Num2endl; cout“m Num3=”m Num3endl; void Add(int i) m Num3+=i; private: int m Numl; const int m Num2; Static int m Num3; *2* ; *3* Void fun() TeStClass Num(1, 2); Num m Numl=4; *4* Num Add(); Num Print(); void main() TeStClass Num(1, 2); Num Print(); fun(); return; 国家二级 C+机试

4、(操作题)模拟试卷 385答案与解析 一、基本操作题 1 【正确答案】 (1)assert(Si zeof(str1)=4); (2)assert(Sizeof(str2)=10); (3)assert(Sizeof(str3)=1); 【试题解析】 本题的功能是利用 assert()函数,则会产生一个中断异常。从已定源程序的 main主函数开始入手,依次执行程序中的语句,输出题目中要求的输出值。本题在调试的时候并不会产生错误,它的错误是逻辑错误。 二、简单应用题 2 【正确答案】 length=0; for (int i=1; i=n; i+) if(n i=0)判断是否 n的因数 desl

5、ength=i; length+; 【试题解析】 函数 factor(int*des, int&length, int n)实现的功能是将 n所有因数存放到 des中,通过 length引用返回因数的个数,求因数可采用取余数的方法,如果两数相除余数为 0则说明除数是被除数的因数。 三、综合应用题 3 【正确答案】 (1)添加语句: TeStClas S(int i, int j): mNum2(j) (2)添加语句: friend void fun(); (3)添加语句: int TestClass: mNum3=0; (4)将 “Num Add(); ”补充完整为: Num Add(5); 【试题解析】 在 VC环境下打开程序,根据题干给出的几条功能要求,对程序中给出注释下的内容逐个补全或修改。从己给定源程序的 main主函数开始入手,可以看出程序通过调用类 TestClass和函数 fun实现各种输出操作。

展开阅读全文
相关资源
猜你喜欢
  • ASD-STAN PREN 2591-F12-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part F12 - Optical Elements Effectiveness of Cable Attachment Cable Axial Co.pdf ASD-STAN PREN 2591-F12-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part F12 - Optical Elements Effectiveness of Cable Attachment Cable Axial Co.pdf
  • ASD-STAN PREN 2591-F15-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part F15 - Optical Elements Connection Integrity at Temperature (Edition P 1.pdf ASD-STAN PREN 2591-F15-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part F15 - Optical Elements Connection Integrity at Temperature (Edition P 1.pdf
  • ASD-STAN PREN 2591-F2-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part F2 - Optical Elements Variation of Attenuation and Optical Discontinuity.pdf ASD-STAN PREN 2591-F2-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part F2 - Optical Elements Variation of Attenuation and Optical Discontinuity.pdf
  • ASD-STAN PREN 2591-F3-1994 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part F3 Change of Power Distribution (Edition P 1)《航空航天系列 电气和光学连接部件 试验方法 第F3部.pdf ASD-STAN PREN 2591-F3-1994 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part F3 Change of Power Distribution (Edition P 1)《航空航天系列 电气和光学连接部件 试验方法 第F3部.pdf
  • ASD-STAN PREN 2591-F4-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part F4 - Optical Elements Cleaning Capability of Optical Face (Edition P 1)《.pdf ASD-STAN PREN 2591-F4-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part F4 - Optical Elements Cleaning Capability of Optical Face (Edition P 1)《.pdf
  • ASD-STAN PREN 2591-F9-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part F9 - Optical Elements Effectiveness of Cable Attachment Cable Cyclic Fle.pdf ASD-STAN PREN 2591-F9-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part F9 - Optical Elements Effectiveness of Cable Attachment Cable Cyclic Fle.pdf
  • ASD-STAN PREN 2591-FA1-1994 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part FA1 - Optical Elements Visual Examination (Edition P 2)《航空航天系列 电气和光学连接部.pdf ASD-STAN PREN 2591-FA1-1994 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part FA1 - Optical Elements Visual Examination (Edition P 2)《航空航天系列 电气和光学连接部.pdf
  • ASD-STAN PREN 2591-FC1-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part FC1 - Optical Elements Endurance at Temperature (Edition P 1)《航空航天系列 电气.pdf ASD-STAN PREN 2591-FC1-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part FC1 - Optical Elements Endurance at Temperature (Edition P 1)《航空航天系列 电气.pdf
  • ASD-STAN PREN 2591-FC14-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part FC14 - Optical Elements Immersion at Low Air Pressure (Edition P 1)《航空.pdf ASD-STAN PREN 2591-FC14-1993 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part FC14 - Optical Elements Immersion at Low Air Pressure (Edition P 1)《航空.pdf
  • 相关搜索

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

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