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

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

1、国家二级 C+机试(操作题)模拟试卷 439及答案与解析 一、基本操作题 1 使用 VC6打开考生文件夹下的源程序文件 modil cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: 1 5 1 注意:错误的语句在 *error*的下面,修改该语句即可。 #include *error* enum Sun, Mon, Tue, Wed, Thu, Fri, Sat, *error* MyEnum; Struct Struct *error* int Fri, int Sun; ; void main() int i=Mon; MyEnum t=Fri; Struct Str1

2、 Str1 Fri=Mon; cout #define MAXNLEN 100 void factor(int *des, int&length, int n) void main() int aMAXNLEN, length; int n=20; factor(a, length, n); for(int i=0; i class CMyFormula private: *1* public: *2* this-a=a; this-b=b; void set(int x, int y) a=x; b=y; void display() *3* ; int main() CMyFormula

3、 formular(1, 1), for(int i=1; i; ”,程序当中把枚举类型名 MyEnum放到枚举声明后面,显然不符合枚举类 型声明格式,因此第 1个标识下应改成 “enum MyEnum”。 (2)由 (1)的分析可知,第 2个标识下也不符合枚举类型声明格式,应以 “; ”结束,即第 2个标识下应改为 “; ”。 (3)第 3标识处声明结构体,结构体定义的一般形式为: struct ; 结构体中成员列表中各个元素是不同的变量,变量之间应以分号隔开,而不是以逗号隔开,因此第 3个标识下应改为为 “int Fri; ”。 二、简单应用题 2 【正确答案】 length=0; for

4、 (int i=1; i=n; i+) if(n i=0)判断是否 n的因数 deslength=i; length+; 【试题解析】 (1)找到 n的每一个因数可采用循环方法,循环变量从 I开始到 n,逐个取 n和循环变量的余数。 (2)如果余数为 0说明是 n的因数,添加到 des中,参数 length是采用的引用传递方式,形参的改变会影响实参,因此可直接将 length的值加 1表示 des中元素个数加 1。 三、综合应用题 3 【正确答案】 (1)添加语句: int a, b; (2)添加语句: CMyFormula(int a=1, int b=1) (3)添加语句: couta*b

5、a*b; (4)将 “for(int j=1; j+)”补充完整为: for(int j=1; j=i; j+) 【试题解析】 (1)第 1个标识下完成 CMyFormula类的私有变量 a、 b的定义,从函数 set(int x, int y)的参数类型可以看出 a和 b均为 int型变量,故第 1个标识下应添加 “int a, b: ”。 (2)第 2个标识下添加构造函数声明,完成 对变量 a、 b赋值,该构造有两个参数 a和 b,且 a和 b缺省值为 1,因此第 2个标识下应添加 “CMyFormula(inta=1, int b=1)”。 (3)打印函数 display()在屏幕上打印出 “a*b=c格式的一个乘法算式,因此第 3个标识下应添加 “couta*b=a*b: ” (4)观察可知第 4个标识下的 for循环是死循环, j没有判断退出条件,会一直循环下去得不到想到的 99的口诀表,外层循环变量 i从 1开始变化至 9,循环 9次,内部循环变量 j应该从 1变化到 i,输出一行, i=i,这 样保证输出的是倒 99口诀,因此第 4个标识下应改为 “for(intj=1; j=i j+)”。

展开阅读全文
相关资源
猜你喜欢
  • STAS SR ISO 6772-1995 Aerospace - Fluid systems - Impulse testing of hydraulic hose tubing and fitting assemblies《航空航天 流体系统 液压软管、导管和接头组件的冲击试验 》.pdf STAS SR ISO 6772-1995 Aerospace - Fluid systems - Impulse testing of hydraulic hose tubing and fitting assemblies《航空航天 流体系统 液压软管、导管和接头组件的冲击试验 》.pdf
  • STAS SR ISO 6777-1996 Water quality - Determination of nitrite - Molecular absorption spectrometric method《水质 亚硝酸盐的测定 分子吸收光度法 》.pdf STAS SR ISO 6777-1996 Water quality - Determination of nitrite - Molecular absorption spectrometric method《水质 亚硝酸盐的测定 分子吸收光度法 》.pdf
  • STAS SR ISO 6779-1996 Acceptance conditions for broaching machines of vertical internal type - Testing of accuracy《立式内拉床验收条件 精度检验 》.pdf STAS SR ISO 6779-1996 Acceptance conditions for broaching machines of vertical internal type - Testing of accuracy《立式内拉床验收条件 精度检验 》.pdf
  • STAS SR ISO 6781-1995 Thermal insulation - Qualitative detection of thermal irregularities in building envelopes - Infrared method《绝热 建筑围护结构热缺陷的定性探测 红外线法 》.pdf STAS SR ISO 6781-1995 Thermal insulation - Qualitative detection of thermal irregularities in building envelopes - Infrared method《绝热 建筑围护结构热缺陷的定性探测 红外线法 》.pdf
  • STAS SR ISO 6786-1995 Road vehicles - Air braking systems - Identification of connections on units《道路车辆 空气制动系统 单位上连接的定义 》.pdf STAS SR ISO 6786-1995 Road vehicles - Air braking systems - Identification of connections on units《道路车辆 空气制动系统 单位上连接的定义 》.pdf
  • STAS SR ISO 6814-1996 Machinery for forestry - Mobile and self-propelled machinery -Identification vocabulary《林业设备 活动和自推式设备 鉴定词汇 》.pdf STAS SR ISO 6814-1996 Machinery for forestry - Mobile and self-propelled machinery -Identification vocabulary《林业设备 活动和自推式设备 鉴定词汇 》.pdf
  • STAS SR ISO 6816-1996 Machinery for forestry - Winches - Classification and no-menclatura《林业机械 卷扬机 分类和命名 》.pdf STAS SR ISO 6816-1996 Machinery for forestry - Winches - Classification and no-menclatura《林业机械 卷扬机 分类和命名 》.pdf
  • STAS SR ISO 6844-1995 Surface active agents - Determination of mineral sulfate content - Titrimetric method《表面活性剂 矿物组成的测定 滴定法 》.pdf STAS SR ISO 6844-1995 Surface active agents - Determination of mineral sulfate content - Titrimetric method《表面活性剂 矿物组成的测定 滴定法 》.pdf
  • STAS SR ISO 6861-1994 Flax or hemp woven fabrics and flax or hemp type woven fabrics Minimal fastness of colours and printings《亚麻或大麻织物和亚麻或大麻型织物 色彩和印花的最小牢固度》.pdf STAS SR ISO 6861-1994 Flax or hemp woven fabrics and flax or hemp type woven fabrics Minimal fastness of colours and printings《亚麻或大麻织物和亚麻或大麻型织物 色彩和印花的最小牢固度》.pdf
  • 相关搜索

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

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