【计算机类职业资格】国家二级C++机试(操作题)模拟试卷348及答案解析.doc
《【计算机类职业资格】国家二级C++机试(操作题)模拟试卷348及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】国家二级C++机试(操作题)模拟试卷348及答案解析.doc(5页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级 C+机试(操作题)模拟试卷 348及答案解析(总分:8.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:2.00)1.请使用 VC6或使用【答题】菜单打开考生文件夹 prog1下的工程 prog1。此工程中包含程序文件maincpp,其中有类 Score(“成绩”)和主函数 main的定义。程序中位于每个“ERROR*found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: 学号:12345678 课程:英语 总评成绩:85 注意:只修改每个“ERROR*found*”下的一行,不要改动程序中的其他内容。#includeiostreamusing na
2、mespace std;class Scorepublic: Score(const char*the course,const char*the id,int the normal,int the midterm,int the end of term) :course(the course),normal(the normal),midterm(the midterm),end of term(the end of term) ERROR*found* strcpy(the id,student_id); const char*getCourse()constreturn course;)
3、返回课程名称ERROR*found* const char*getID()constreturn 总评成绩中平时成绩占 20,期中考试占 30,期末考试占 50,最后结果四舍五入为 一个整数 ERROR*found* int getFinal()const return normal*02+midterm*03+end_of_term*05+05;int main() char English=”英语”; Score score(English,”12345678”,68,83,92);cout”学号:”scoregetID()“;cout”课程:”scoregetCourse()”; cou
4、t”总评成绩:”scoregetFinal()endl; return 0;(分数:2.00)_二、简单应用题(总题数:2,分数:4.00)2.请使用 VC6或使用【答题】菜单打开考生文件夹 proj2下的工程 proj2,此工程中含有一个源程序文件proj2epp。函数 char*GetNum(char*src,char*buf)从 src开始扫描下一个数字字符序列,并将其作为一个字符串取出放人字符串空间 buf中。函数返回扫描的终止位置,如果返回 NULL表示没有扫描到数字字符序列。 运行程序时,如果输入的一行字符序列是 ABC012XYZ378MN274WS 则输出为: Digit st
5、ring 1 is 012 Digit string 2 is 378 Digit string 3 is 274 注意:只在横线处编写适当代码,不要删除或移动“*found*”.proj2cpp#includeiostreamusing namespace std;char*GetNum(char*see,char*bur) while(*src!=0) if(isdigit(*src)break; SrC+; if(*src=0)/*found*_;while(*src!=0 protected: int*a; unsigned int size,num;;class SortedArra
6、y:public Arraypublic:/*found* SortedArray(unsigned int S) :_ virtual void add(int e) if(num=Size) return; int i=0,j; while(inum) if(eai) for(j=num;ji;j一)*found* _; *found* _; break; i+; if(i=num) ai=e; num+; ;void fun(Array for(i=0;i10;i+) coutaget(i)”,”; coutendl;int main() Array a(10); fun(a); Sor
7、tedArray sa(10); fun(sa); return 0;(分数:2.00)_三、综合应用题(总题数:1,分数:2.00)4.请使用 VC6或使用【答题】菜单打开考生文件夹 proj3下的工程 pmj3,其中声明了一个单向链表类sList。sLst 的成员函数 Prepend的功能是在链表头部加入一个新的元素。请编写成员函数 Prepend。在main函数中给出了一组测试数据,此时程序的输出应为: B 一A 一 # A 一 # A 一 # exiting inner block exiting outer block 注意:只在函数 Prepend的“*333*”和“*666*”之
8、间填入若干语句,不要改动程序中的其他内容。/SListhstruct sListItem char data; sListItem*next;class sListpublic: sList():h(0)0 表示空链表 sList(); void Prepend(char c);在链表前端加入元素 void Del();删除链表首元素 sListItem*First()constreturnh;返回链表首元素 void Print()const;打印链表内容 void Release();销毁链表 private: sListItem* h;/链表头;void writeToFile(cons
9、t char* );maincpp#includeiostream#include”sListh”us ing namespace std;sList:一 sList() Release(); void sList:Prepend(char C) *333* /*666* void sList:Del() sListItem*temp=h; h=h 一next; delete temp; void sList:Print()const sListItem*temp=h; while(temp!=0) 判断是否到达链表尾部 couttemp 一data”一”; temp=temp 一next;
10、cout”n#”endl;void sList:Release() while(h!=0) Del();int main() sLisL*ptr; sList obj; objPrepend(A); objPrepend(B); objPrint(); objDel(); objPrint(); pfir=obj; pLr 一Print();tout”exiting inner block”end1; couL”exiting outer block”endl; writeToFile(”); return 0;(分数:2.00)_国家二级 C+机试(操作题)模拟试卷 348答案解析(总分:8
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 国家 二级 机试 操作 模拟 试卷 348 答案 解析 DOC
