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

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

1、国家二级 C+机试(操作题)模拟试卷 373及答案解析(总分:6.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:2.00)1.使用 VC6打开考生文件夹下的源程序文件 modilcpp,该程序运行时有错,请改正其中的错误,使程序正常运行,并且使程序输出的结果为: a=7,b=0 a=8,b=10 注意:错误的语句在*error*的下面,修改该语句即可。 #include class CObj public: *error* friend void func(CObj,int, int); void di splay() *error* coutn; if(n=1) break;

2、 while(1); for(int i=0;iXXij; coutn; if(n=1) break; while(1); for(int i=0;iXXij; coutfun(n)_正确答案:(正确答案:int data=0; 初始化求平方和变量 for(int i=0; in;i+) data+=XXii*XXii; 求正对角线平方和 if(i!=ni 一 1) data+=XXini1*XXini一 1;求逆对角线平方和 return data;)解析:解析:本题函数中的功能是输出 N行 N列正方阵,然后求两条对角线上各元素之平方和。其中,假设矩阵行、列分别为 i、j,那么对角线上的元素

3、特点是主对角线上 i=j,以及逆对角线 j=ni一 1。三、综合应用题(总题数:1,分数:2.00)3.使用 VC6打开考生文件夹下的源程序文件 modi3cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)定义私有数据成员 year、month、day,分别用于年、月、日,它们都是 int型的数据,请在注释 *1*后添加适当的语句。 (2)完成判断数据成员 date2是否是闰年函数 intDate:IsLeapYear0 的定义,返回数据成员 date2是否是闰年的值,是则返回 1,否则返回 0。请在注释 *2*后添加适当的语句。 (3)设置 SetData0的默认

4、时间为:2004121,请在注释 *3*后添加适当的语句。 (4)完成主函数 main(),完成输出 date2 is aleapyear,请在注释 *4*后添加适当的语句。 提示:公元纪年的年数可以被四整除,即为闰年;被 100整除而不能被 400整除为平年;被 100整除也可被 400整除的为闰年。 注意:增加或修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。 #include using namespace std; Class Date public: *3* void SetDate(int y,int m,int n); int IsLeapYear(); void P

5、rint() coutyear“一” “一” day endl; private: *1* ; void Date:SetDate(int y,int m,int d) year=y; month=m; day=d; int Date:IsLeapYear() *2* return int main() Date datel,date2; datelSetDate(); date2SetDate(2 00 4,1 2,1); cout “date2 is”_正确答案:(正确答案:(1)int year,month,day; (2)将“return”补充完整为:return fyear400=0

6、)I f(year4=0&year100 1=0); (3)将“void SetDate(int y,int m,intn);”补充完整为: void SetDate(inty=2004,int m=12,int n=1); (4)将“cout(“”:“not”)end1;”补充完整为:cout(date2IsLeapYear()?”:“not”)end1;)解析:解析:本题中程序的功能是判断 2004年是否为闰年。其中成员函数 SetDate设置日期,IsLeapYear函数判断是否为闰年。在 VC环境下打开程序,根据题干给出的几条功能要求,对程序中给出注释下的内容逐个补全或修改。从己定源程序的 main主函数开始入手,可以看出程序通过调用类 Date和和其成员函数实现各种功能。

展开阅读全文
相关资源
猜你喜欢
  • EN ISO 4516-2002 en Metallic and Other Inorganic Coatings - Vickers and Knoop Microhardness Tests《金属和其他无机镀层 维氏硬度计和努氏显微硬度试验机 ISO 4516-2002》.pdf EN ISO 4516-2002 en Metallic and Other Inorganic Coatings - Vickers and Knoop Microhardness Tests《金属和其他无机镀层 维氏硬度计和努氏显微硬度试验机 ISO 4516-2002》.pdf
  • EN ISO 4518-1995 en Metallic Coatings - Measurement of Coating Thickness - Profilometric Method《金属镀层 镀层厚度的测量 表面光法度轮廓仪法(ISO 4518-1990)》.pdf EN ISO 4518-1995 en Metallic Coatings - Measurement of Coating Thickness - Profilometric Method《金属镀层 镀层厚度的测量 表面光法度轮廓仪法(ISO 4518-1990)》.pdf
  • EN ISO 4519-2016 en Electrodeposited metallic coatings and related finishes - Sampling procedures for inspection by attributes《电沉积金属层和有关完成计数抽样检查程序(ISO 4519 1980)》.pdf EN ISO 4519-2016 en Electrodeposited metallic coatings and related finishes - Sampling procedures for inspection by attributes《电沉积金属层和有关完成计数抽样检查程序(ISO 4519 1980)》.pdf
  • EN ISO 4521-2008 en Metallic and other inorganic coatings - Electrodeposited silver and silver alloy coatings for engineering purposes - Specification and test methods《金属和其他无机覆盖层 工.pdf EN ISO 4521-2008 en Metallic and other inorganic coatings - Electrodeposited silver and silver alloy coatings for engineering purposes - Specification and test methods《金属和其他无机覆盖层 工.pdf
  • EN ISO 4524-3-1995 en Metallic Coatings - Test Methods for Electrodeposited Gold and Gold Alloy Coatings - Part 3 Electrographic Tests for Porosity《金属镀层 电镀金和金合金镀层的测试方法 第3部分 孔隙率的电刻器.pdf EN ISO 4524-3-1995 en Metallic Coatings - Test Methods for Electrodeposited Gold and Gold Alloy Coatings - Part 3 Electrographic Tests for Porosity《金属镀层 电镀金和金合金镀层的测试方法 第3部分 孔隙率的电刻器.pdf
  • EN ISO 4524-6-1994 en Metallic Coatings - Test Methods for Electrodeposited Gold and Gold Alloy Coatings - Part 6 Determination of the Presence of Residual Salts《金属镀层 电镀金和金合金镀层的测试方.pdf EN ISO 4524-6-1994 en Metallic Coatings - Test Methods for Electrodeposited Gold and Gold Alloy Coatings - Part 6 Determination of the Presence of Residual Salts《金属镀层 电镀金和金合金镀层的测试方.pdf
  • EN ISO 4526-2004 en Metallic coatings - Electroplated coatings of nickel for engineering purposes《金属覆层 工程用镍电镀层》.pdf EN ISO 4526-2004 en Metallic coatings - Electroplated coatings of nickel for engineering purposes《金属覆层 工程用镍电镀层》.pdf
  • EN ISO 4527-2003 en Metallic coatings Autocatalytic (electroless) nickel-phosphorus alloy coatings Specification and test methods《金属镀层 自催化镍-磷合金电镀层 规范和试验方法 ISO 4527-2003》.pdf EN ISO 4527-2003 en Metallic coatings Autocatalytic (electroless) nickel-phosphorus alloy coatings Specification and test methods《金属镀层 自催化镍-磷合金电镀层 规范和试验方法 ISO 4527-2003》.pdf
  • EN ISO 4528-2009 781 Vitreous and porcelain enamel finishes - Selection of test methods for vitreous and porcelain enamelled areas of articles《釉瓷和搪瓷精饰 产品的釉瓷和搪瓷区域的试验方法的选择》.pdf EN ISO 4528-2009 781 Vitreous and porcelain enamel finishes - Selection of test methods for vitreous and porcelain enamelled areas of articles《釉瓷和搪瓷精饰 产品的釉瓷和搪瓷区域的试验方法的选择》.pdf
  • 相关搜索

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

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