[计算机类试卷]国家二级C++机试(操作题)模拟试卷203及答案与解析.doc
《[计算机类试卷]国家二级C++机试(操作题)模拟试卷203及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级C++机试(操作题)模拟试卷203及答案与解析.doc(8页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级 C+机试(操作题)模拟试卷 203及答案与解析 一、基本操作题 1 请使用 VC6或使用【答题】菜单打开考生文件夹 proj1下的工程 proj1,该工程中包含程序文件 main cpp,其中有类 Clock(“时钟 ”)的定义和主函数 main的定义。程序中位于每个 “ ERROR*found*”之后的一行语句有错误请加以改正。改正后程序的输出结果应为: Initial times are 0d: 0h: 0m: 59s After one second times are 0d: 0h: 1m: 0s 注意:只修改每个 “ ERROR*found*”下的那一行,不要改动程序中的其
2、他内容。 1 #include 2 using namespace std; 3 4 class Clock 5 6 public: 7 Clock(unsigned long i=0); 8 void set(unsigned long i=0); 9 void print()const; 10 void tick(); 时间前进一秒 11 Clock operator+(); 12 private: 13 uns igned long total sec, seconds minutes, hours, days; 14 ; 15 Clock: Clock(unsigned long i)
3、 : total_sec(i), seconds(i 60), minutes(i 60) 60), hours(i 3600) 24), days(i 86400) 16 void Clock: set(unsigned long i) 17 18 total sec=i; 19 seconds=i 60; 20 minutes: (i 60) 60; 21 hours=(i 3600) 60; 22 days: i 86400; 23 24 ERROR *found* 25 void Clock: print() 26 27 cout 2 using namespace std; 3 cl
4、ass Room “房间 ”类 4 int room no; 房间号 5 double length; 房间长度 (m) 6 double width; 房间宽度 (m) 7 public: 8 Room(int the_room_no, double the_length, double the_width):room_no(the_room_no), length(the_length), width(the_width) 9 int theRoomNo()constreturn room_ 10 no;) 11 返回房间号 12 double theLength()constreturn
5、length; ) 返回房间长度 13 double theWidth()const return width; 返回房间宽度 14 *found* 15 double theArea()const _返回房间面积 (矩形面积 ) 16 ; 17 class Office: public Room “办公室 “类 18 char*depart; 所属部门 19 public: 20 Office(int the_room_no,double the_ length, double the_width, constchar*the_depart) 21 *found* 22 : _ 23 dep
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 机试 操作 模拟 203 答案 解析 DOC
