【计算机类职业资格】三级网络技术机试-251及答案解析.doc

上传人:eveningprove235 文档编号:1321954 上传时间:2019-10-17 格式:DOC 页数:5 大小:28KB
下载 相关 举报
【计算机类职业资格】三级网络技术机试-251及答案解析.doc_第1页
第1页 / 共5页
【计算机类职业资格】三级网络技术机试-251及答案解析.doc_第2页
第2页 / 共5页
【计算机类职业资格】三级网络技术机试-251及答案解析.doc_第3页
第3页 / 共5页
【计算机类职业资格】三级网络技术机试-251及答案解析.doc_第4页
第4页 / 共5页
【计算机类职业资格】三级网络技术机试-251及答案解析.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

1、三级网络技术机试-251 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是实现从文件 IN35DAT 中读取一篇英文文章存入到字符串数组 xx 中。请编制函数 SortCharD(),该函数的功能是:以行为单位对字符按从大到小的顺序进行排序,排序后的结果仍按行重新存入字符串数组 xx 中,最后调用函数 WriteDat()把结果 xx 输出到文件 OUT35DAT 中。例如,原文:dAe,BfCCCbbAA结果:fedCBA,bbCCAA原始数据文件存放的格式是:每行的宽度均小于 80 个字符,含标点符号和空

2、格。注意;部分源程序已给出。请勿改动主函数 main()、读函数 ReadDat()和写函数 WrteDat()的内容。试题程序:#includeStdioh#includeStringh#includeconiohchar xx5080;int maxline=0;int ReadDat(void);void WriteDat(void);void SortCharD()void main()Clrscr();if (ReadDat()printf(“数据文件 IN35.DAT 不能打开!/n/007“);return;SortChar D();WriteDat();int ReadDat(

3、void)FILE *fp;int i=0;Char*p;if(fp:fOpen(“IN35.DAT“,“r“)=NULL)return 1;while (fgets(xXi,80,fp)!=NULL)p=strchr(xXi,“/n“);if (p) *p:0;i+;maxline=i;fclose(fp);return 0;void WriteDat()FILE *fp;int i;Clrscr();fp:fopen(“OUT35.DAT“,“w“);for(i:0;imaxline;i+)printf(“%s/“,xxi);fprintf(fp,“%s/n“,xxi); fclose(f

4、p);(分数:100.00)_三级网络技术机试-251 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是实现从文件 IN35DAT 中读取一篇英文文章存入到字符串数组 xx 中。请编制函数 SortCharD(),该函数的功能是:以行为单位对字符按从大到小的顺序进行排序,排序后的结果仍按行重新存入字符串数组 xx 中,最后调用函数 WriteDat()把结果 xx 输出到文件 OUT35DAT 中。例如,原文:dAe,BfCCCbbAA结果:fedCBA,bbCCAA原始数据文件存放的格式是:每行的宽度均小于

5、80 个字符,含标点符号和空格。注意;部分源程序已给出。请勿改动主函数 main()、读函数 ReadDat()和写函数 WrteDat()的内容。试题程序:#includeStdioh#includeStringh#includeconiohchar xx5080;int maxline=0;int ReadDat(void);void WriteDat(void);void SortCharD()void main()Clrscr();if (ReadDat()printf(“数据文件 IN35.DAT 不能打开!/n/007“);return;SortChar D();WriteDat(

6、);int ReadDat(void)FILE *fp;int i=0;Char*p;if(fp:fOpen(“IN35.DAT“,“r“)=NULL)return 1;while (fgets(xXi,80,fp)!=NULL)p=strchr(xXi,“/n“);if (p) *p:0;i+;maxline=i;fclose(fp);return 0;void WriteDat()FILE *fp;int i;Clrscr();fp:fopen(“OUT35.DAT“,“w“);for(i:0;imaxline;i+)printf(“%s/“,xxi);fprintf(fp,“%s/n“,

7、xxi); fclose(fp);(分数:100.00)_正确答案:(void SortCharD()int i, j, k, strl;char ch;for (i=0;imaxline;i+)strl=strlen (xx i ); /*求各行的长度*/for (j=0; jfor (k=j+l; kif (xxi jch=xxi j;xxi j=xxi k;xxi k =ch;)解析:解析 本题考查的知识点如下:(1)循环结构的嵌套。(2)字符的大小比较。(3)字符排序。 本题以行为单位对文章进行处理,首先要确定每一行中字符的个数。这个操作可使用字符串处理函数 strlen(char*str)来完成。对字符从大到小排序依据的是字符的 ASCII 码,在 C 语言中,字符量可参与任何整型运算,所以可以直接使用比较运算符进行比较。排序使用前面介绍的“选择排序法”。最后使用循环结构对文章中的每一行都进行以上的操作。

展开阅读全文
相关资源
猜你喜欢
  • ISO 15883-4-2008 Washer-disinfectors - Part 4 Requirements and tests for washer-disinfectors employing chemical disinfection for thermolabile endoscopes《垫圈-消毒器具.pdf ISO 15883-4-2008 Washer-disinfectors - Part 4 Requirements and tests for washer-disinfectors employing chemical disinfection for thermolabile endoscopes《垫圈-消毒器具.pdf
  • ISO 15883-6-2011 Washer-disinfectors - Part 6 Requirements and tests for washer-disinfectors employing thermal disinfection for non-invasive non-critical medica.pdf ISO 15883-6-2011 Washer-disinfectors - Part 6 Requirements and tests for washer-disinfectors employing thermal disinfection for non-invasive non-critical medica.pdf
  • ISO 15884-2002 Milk fat - Preparation of fatty acid methyl esters《乳脂 脂肪酸甲酯制备》.pdf ISO 15884-2002 Milk fat - Preparation of fatty acid methyl esters《乳脂 脂肪酸甲酯制备》.pdf
  • ISO 15885-2002 Milk fat - Determination of the fatty acid composition by gas-liquid chromatography《乳脂 用气相液相色谱分析法测定脂肪酸组分》.pdf ISO 15885-2002 Milk fat - Determination of the fatty acid composition by gas-liquid chromatography《乳脂 用气相液相色谱分析法测定脂肪酸组分》.pdf
  • ISO 15886-3 AMD 1-2016 Agricultural irrigation equipment - Sprinklers - Part 3 Characterization of distribution and test methods Amendment 1《农业灌溉设备 洒水装置 第3部分 分布.pdf ISO 15886-3 AMD 1-2016 Agricultural irrigation equipment - Sprinklers - Part 3 Characterization of distribution and test methods Amendment 1《农业灌溉设备 洒水装置 第3部分 分布.pdf
  • ISO 15886-3-2012 Agricultural irrigation equipment - Sprinklers - Part 3 Characterization of distribution and test methods《农业灌溉设备 洒水装置 第3部分 分布表征和试验方法》.pdf ISO 15886-3-2012 Agricultural irrigation equipment - Sprinklers - Part 3 Characterization of distribution and test methods《农业灌溉设备 洒水装置 第3部分 分布表征和试验方法》.pdf
  • ISO 15888-2000 Space data and information transfer systems - Standard formatted data units - Referencing environment《空间数据和信息传输系统 标准格式化数据单元 参照环境》.pdf ISO 15888-2000 Space data and information transfer systems - Standard formatted data units - Referencing environment《空间数据和信息传输系统 标准格式化数据单元 参照环境》.pdf
  • ISO 15901-2 CORR 1-2007 Pore size distribution and porosity of solid materials by mercury porosimetry and gas adsorption - Part 2 Analysis of mesopores and macr.pdf ISO 15901-2 CORR 1-2007 Pore size distribution and porosity of solid materials by mercury porosimetry and gas adsorption - Part 2 Analysis of mesopores and macr.pdf
  • ISO 15902 CORR 1-2005 Optics and photonics - Diffractive optics - Vocabulary Technical Corrigendum 1《光学和光子学 衍射光学 词汇 技术勘误1》.pdf ISO 15902 CORR 1-2005 Optics and photonics - Diffractive optics - Vocabulary Technical Corrigendum 1《光学和光子学 衍射光学 词汇 技术勘误1》.pdf
  • 相关搜索

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

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