[计算机类试卷]国家二级C++机试(操作题)模拟试卷219及答案与解析.doc
《[计算机类试卷]国家二级C++机试(操作题)模拟试卷219及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级C++机试(操作题)模拟试卷219及答案与解析.doc(9页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级 C+机试(操作题)模拟试卷 219及答案与解析 一、基本操作题 1 请使用 VC6或使用【答题】菜单打开考生文件夹 proj1下的工程 proj1,其中有枚举 DOGCOLOR、狗类 Dog和主函数 main的定义。程序中位于每个 “ERROR*found*”下的语句行有错误,请加以改正。改正后程序的输出结果应该是: There is a white dog named Hoho There is a black dog named Haha There is a motley dog named Hihi 注意:只修改每个 “ ERROR*found*”下的那一行,不要改动程序中的
2、其他内容。 1 #include 2 using namespace std; 3 狗的颜色:黑、白、黄、褐、花、其他 4 enum DOGCOLORBLACK, WHITE, YELLOW, BROWN, PIEBALD, OTHER); 5 class Dog狗类 6 DOGCOLOR color ; 7 char name2 0; 8 static int count; 9 public: 10 Dog(char name, DOGCOLOR color) 1l strcpy(this-name, name); 12 ERROR *found* 13 strcpy(this-color,
3、 color); 14 15 DOGCOLOR getColor()constreturncolor; 16 ERROR *found* 17 const char*getName()constre- turn*name; 18 const char* getColrString() const 19 switch(color) 20 case BLACK: return“black“; 21 case WHITE: return“white“; 22 case YELLOW: return“yellow“; 23 case BROWN: return“brown“; 24 case PIEB
4、ALD: return“piebald“; 25 26 return”motley”; 27 28 void show()const 29 cout 4 double length(Point p1, Point p2) 5 6 return sqrt(p1 getX()-p2 getX()*(p1 getX()-p2 getX()+(p1 getY()-p2 getY()*(p1 getY()-p2 getY(); 7 8 double Triangle: perimeter()const 9 一个 return语句,它利用 length函数计算并 返回三角形的周长 10 *found* 1
5、1 _; 12 13 14 double Triangle: area()const 15 16 double s=perimeter() 2 0; 17 return sqrt(s*(s-length(point1, point2)* 18 (s-length(point2, point3), * 19 (s-length(point3, point1); 20 1 proj2 cpp 2 #include“shape h“ 3 #include 4 using namespace std; 5 6 *found* 7 _ show函数的函数头 (函数体以前的部分 ) 8 9 cout 3
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 机试 操作 模拟 219 答案 解析 DOC
