[计算机类试卷]国家二级C++机试(操作题)模拟试卷61及答案与解析.doc
《[计算机类试卷]国家二级C++机试(操作题)模拟试卷61及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级C++机试(操作题)模拟试卷61及答案与解析.doc(7页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级 C+机试(操作题)模拟试卷 61及答案与解析 一、基本操作题 1 使用 VC6打开考生文件夹下的源程序文件 modil cpp,但该程序运行有问题,请改正 main函数中的错误,使程序的输出结果是: 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 注意:不要改动 main函数,不能增行或删行,也不能更改程序的结构,错误的语句在 *error*的下面。 1 #include 2 #include 3 void main()f 4 int a33=1, 2, 3), 4, 5, 6), 7, 8, 9); 5 int *p, i ; 6 *error* 7 P=a
2、; 8 for(i=0 ; i 2 int fun(char*data) 3 4 5 6 void main() 7 8 char Str1024; 9 cout 2 class MyFileClasS 3 4 private: 5 char filename64; 6 char*contex; 7 int FileLength; 8 public: 9 MyFileClasS() 10 11 *1* 12 13 contex=NULL; 14 FileLength=0; 15 16 MyFileClasS() 17 18 if(FileLength) 19 *2* 20 21 22 void
3、 OpenFile(char*str, int len) 23 24 for(int i=0 ; ilen; i+) 25 26 filenamei=stri; 27 28 filenamelen=0; 29 FileLength=0; 30 if(contex) 31 32 deletecontex; 33 contex=NULL; 34 35 36 void WriteFlie(char*str, int len) 37 38 if(contex!=NULL) 39 *3* 40 41 contex=new char1en+1; 42 for(int i=0; ilen; i+) 43 c
4、ontexi=stri; 44 contex1en=0 ; 45 FileLength=len; 46 47 void CopyFile(MyFileClass&file) 48 49 *4* 50 51 52 void display() 53 54 Coutcontexendl; 55 56 ; 57 int main() 58 59 MyFileClass filel, file2 ; 60 filel OpenFile(“txtl“, 4); i61 file2 OpenFile(“txt2“, 4); 62 filel WriteFlie(“hello!“, 6); 63 file2
5、 CopyFile(filel); 64 file1 display(); 65 file2 display(); 66 return 0 ; 67 国家二级 C+机试(操作题)模拟试卷 61答案 与解析 一、基本操作题 1 【正确答案】 (1)P=&a00; (2)coutsetw(2)*(*a+i); 【试题解析】 从已给定源程序的 main主函数开始入手,可以看出程序是通过数组与指针两种方法输出数组值。 解题思路 (1)打开 modil cpp,调试程序,显示错误提示为第一标识下 “modi1 cpp(71:error C2440: =: cannot conve fromint33to
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 机试 操作 模拟 61 答案 解析 DOC
