【计算机类职业资格】计算机三级(信息管理技术)上机考试20及答案解析.doc

上传人:appealoxygen216 文档编号:1337210 上传时间:2019-10-17 格式:DOC 页数:2 大小:29KB
下载 相关 举报
【计算机类职业资格】计算机三级(信息管理技术)上机考试20及答案解析.doc_第1页
第1页 / 共2页
【计算机类职业资格】计算机三级(信息管理技术)上机考试20及答案解析.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

1、计算机三级(信息管理技术)上机考试 20 及答案解析(总分:-1.00,做题时间:90 分钟)1.函数 ReadDat()的功能是实现从文件 IN2.DAT 中读取一篇英文文章存入到字符串数组 xx 中;请编制函数 StrOL(),该函数的功能是:以行为单位对行中以空格或标点符号为分隔的所有单词进行倒排。最后把已处理的字符串(应不含标点符号)仍按行重新存入字符串数组 xx 中,最后调用函数 WriteDat()把结果xx 输出到文件 OUT2.DAT 中。 例如,原文:You He Me I am a student. 结果:Me He You student a am I 原始数据文件存放的

2、格式是:每行的宽度均小于 80 个字符,含标点符号和空格。 注意:部分源程序已给出。 请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。 试题程序: #include #include #include #include char xx5080; int maxline = 0;/* 文章的总行数 */ int ReadDat(void); void WriteDat(void); void StrOL(void) main() clrscr(); if (ReadDat () printf(“数据文件 IN2.DAT 不能打开!n007“); re

3、turn; StrOL(); WriteDat(); int ReadDat(void) FILE *fp; int i = 0; char *p; if(fp = fopen(“IN2.DAT“, “r“) = NULL) return 1; while(fgets(xxi, 80, fp) != NULL) p = strchr(xx i, n); if(p) *p = 0; i+; maxline = i; fclose(fp); return 0; void WriteDat(void) FILE*fp; int i; clrscr(); fp = fopen(“OUT2.DAT“,

4、w“); for(i = 0; i =a j=0;j-)/*从当前行的最后一个字符开始取字符,直到遇到空格*/ ppj+1=ppj; pp0=xxli; k+;i-; strcat(ch,pp); /*把该单词存放到数组 ch 中*/ strcpy(pp, “); /*清空数组 pp*/ k=1; if(i=-1)break; /*如果处理完了一行,则退出循环*/ while(xxli9j=0;j-) ppj+1=ppj; pp0=xxli; k+; i-; strcat(ch,pp); /*把空格加到数组ch 中*/ strcpy(pp,“); /*清空数组 pp*/ k=0; if(i=

5、1)break; /*如果处理完了一行,则退出循环*/ strcpy(xxl,ch); /*把已处理的字符串仍按行重新存入字符串数组 xx 中*/ )解析:本题是有关字符串的处理问题。首先利用二重循环来按照先行后列的顺序取得 xx 数组中的各个字符元素,这里用到了 strlen()函数,用来求字符串长度。对依次取得的字符做一些处理,即把多余的标点符号去掉,使新的字符数组中只含有字母和空格。准备工作做完后,从当前行的最后一个字符开始取,不断的取每一个字符前面的字符,直到取得一个完整的单词后(即遇到空格分隔时),就把该单词存放到数组 ch 中(用到了 strcat()函数来连接两个字符串,用 strlen()函数来对字符串求取串长度),还要把分隔符也放到 ch 中去。接着去取该行中其他的字符组成的单词,重复上面的操作,对其他行同样处理。这样最终得到的字符串就是各行中单词出现的顺序的逆序了,但单词本身的字符顺序没有发生变化。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 14447-2005 Fibre reinforced plastics - Glass mat reinforced thermoplastics (GMT) - Determination of flowability and solidification German version of EN 14447 2005《纤维增强塑料 玻璃垫.pdf DIN EN 14447-2005 Fibre reinforced plastics - Glass mat reinforced thermoplastics (GMT) - Determination of flowability and solidification German version of EN 14447 2005《纤维增强塑料 玻璃垫.pdf
  • DIN EN 14449-2005 Glass in building - Laminated glass and laminated safety glass - Evaluation of conformity Product standard German version EN 14449 2005《建筑物玻璃 夹层玻璃和夹层安全玻璃 合格评价 产品标.pdf DIN EN 14449-2005 Glass in building - Laminated glass and laminated safety glass - Evaluation of conformity Product standard German version EN 14449 2005《建筑物玻璃 夹层玻璃和夹层安全玻璃 合格评价 产品标.pdf
  • DIN EN 14451-2005 Devices to prevent pollution by backflow of potable water - In-line anti-vacuum valves DN 8 to DN 80 - Family D type A German version EN 14451 2005《防饮用水回流污染的装置 直通.pdf DIN EN 14451-2005 Devices to prevent pollution by backflow of potable water - In-line anti-vacuum valves DN 8 to DN 80 - Family D type A German version EN 14451 2005《防饮用水回流污染的装置 直通.pdf
  • DIN EN 14452-2005 Devices to prevent pollution by backflow of potable water - Pipe interrupter with atmospheric vent and moving element DN 10 to DN 20 - Family D type B German vers.pdf DIN EN 14452-2005 Devices to prevent pollution by backflow of potable water - Pipe interrupter with atmospheric vent and moving element DN 10 to DN 20 - Family D type B German vers.pdf
  • DIN EN 14453-2005 Devices to prevent pollution by backflow of potable water - Pipe interrupter with permanent atmospheric vent DN 10 to DN 20 - Family D type C German version EN 14.pdf DIN EN 14453-2005 Devices to prevent pollution by backflow of potable water - Pipe interrupter with permanent atmospheric vent DN 10 to DN 20 - Family D type C German version EN 14.pdf
  • DIN EN 14454-2005 Devices to prevent pollution by backflow of potable water - Hose union backflow preventer DN 15 to DN 32 - Family H type A German version EN 14454 2005《防饮用水回流污染的装.pdf DIN EN 14454-2005 Devices to prevent pollution by backflow of potable water - Hose union backflow preventer DN 15 to DN 32 - Family H type A German version EN 14454 2005《防饮用水回流污染的装.pdf
  • DIN EN 14455-2005 Devices to prevent pollution by backflow of potable water - Pressurised air inlet valves DN 15 to DN 50 - Family L type A and type B German version EN 14455 2005《.pdf DIN EN 14455-2005 Devices to prevent pollution by backflow of potable water - Pressurised air inlet valves DN 15 to DN 50 - Family L type A and type B German version EN 14455 2005《.pdf
  • DIN EN 14456-2004 Products used for treatment of water intended for human consumption - Bone charcoal German version EN 14456 2004《人类生活用水处理用制品 骨炭》.pdf DIN EN 14456-2004 Products used for treatment of water intended for human consumption - Bone charcoal German version EN 14456 2004《人类生活用水处理用制品 骨炭》.pdf
  • DIN EN 14457-2004 General requirements for components specifically designed for use in trenchless construction of drains and sewers German version EN 14457 2004《专门为无槽排水和排污结构所设计的构件的.pdf DIN EN 14457-2004 General requirements for components specifically designed for use in trenchless construction of drains and sewers German version EN 14457 2004《专门为无槽排水和排污结构所设计的构件的.pdf
  • 相关搜索

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

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