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

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

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

2、格。 注意;部分源程序已给出。 请勿改动主函数 main()、读函数 ReadDat()和写函数 WrteDat()的内容。 试题程序: #includeStdioh #includeStringh #includeconioh char 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(); Write

3、Dat(); 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“,

4、xxi); fprintf(fp,“%s/n“,xxi); fclose(fp); (分数:-1.00)_三级网络技术-75 答案解析(总分:-1.00,做题时间:90 分钟)一、上机题(总题数:1,分数:-1.00)1.函数 ReadDat()的功能是实现从文件 IN35DAT 中读取一篇英文文章存入到字符串数组 xx 中。请编制函数 SortCharD(),该函数的功能是:以行为单位对字符按从大到小的顺序进行排序,排序后的结果仍按行重新存入字符串数组 xx 中,最后调用函数 WriteDat()把结果 xx 输出到文件 OUT35DAT 中。 例如,原文:dAe,BfC CCbbAA 结果

5、fedCBA, bbCCAA 原始数据文件存放的格式是:每行的宽度均小于 80 个字符,含标点符号和空格。 注意;部分源程序已给出。 请勿改动主函数 main()、读函数 ReadDat()和写函数 WrteDat()的内容。 试题程序: #includeStdioh #includeStringh #includeconioh char xx5080; int maxline=0; int ReadDat(void); void WriteDat(void); void SortCharD() void main() Clrscr(); if (ReadDat() printf(“数据文件

6、 IN35.DAT 不能打开!/n/007“); return; SortChar D(); WriteDat(); 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

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

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 12322-1999 In vitro diagnostic medical devices - Culture media for microbiology - Performance criteria for culture media German version EN 12322 1999《体外诊断医疗装置 微生物用培养基 培养基的功能.pdf DIN EN 12322-1999 In vitro diagnostic medical devices - Culture media for microbiology - Performance criteria for culture media German version EN 12322 1999《体外诊断医疗装置 微生物用培养基 培养基的功能.pdf
  • DIN EN 12323-2005 AIDC technologies - Symbology specifications - Code 16K German version EN 12323 2005《AIDC技术 符号规范 16K码》.pdf DIN EN 12323-2005 AIDC technologies - Symbology specifications - Code 16K German version EN 12323 2005《AIDC技术 符号规范 16K码》.pdf
  • DIN EN 12324-1-1999 Irrigation technic - Reel machine systems - Part 1 Size series German version EN 12324-1 1998《灌溉方法 喷灌用绕软管轮系统 第1部分 尺寸系列》.pdf DIN EN 12324-1-1999 Irrigation technic - Reel machine systems - Part 1 Size series German version EN 12324-1 1998《灌溉方法 喷灌用绕软管轮系统 第1部分 尺寸系列》.pdf
  • DIN EN 12324-2-1999 Irrigation techniques - Reel machine systems - Part 2 Specifications of polyethylene tubes for reel machines German version EN 12324-2 1999《灌溉技术 喷灌机 第2部分 灌溉机用聚乙.pdf DIN EN 12324-2-1999 Irrigation techniques - Reel machine systems - Part 2 Specifications of polyethylene tubes for reel machines German version EN 12324-2 1999《灌溉技术 喷灌机 第2部分 灌溉机用聚乙.pdf
  • DIN EN 12324-3-1999 Irrigation techniques - Reel machine systems - Part 3 Presentation of technical characteristics German version EN 12324-3 1999《灌溉方法 喷灌机 第3部分 技术特性值说明》.pdf DIN EN 12324-3-1999 Irrigation techniques - Reel machine systems - Part 3 Presentation of technical characteristics German version EN 12324-3 1999《灌溉方法 喷灌机 第3部分 技术特性值说明》.pdf
  • DIN EN 12324-4-1999 Irrigation techniques - Reel machine systems - Part 4 Check list of user requirements German version EN 12324-4 1999《灌溉技术 喷灌机 第4部分 用户要求检验单》.pdf DIN EN 12324-4-1999 Irrigation techniques - Reel machine systems - Part 4 Check list of user requirements German version EN 12324-4 1999《灌溉技术 喷灌机 第4部分 用户要求检验单》.pdf
  • DIN EN 12325-1-1999 Irrigation technic - Centre pivot and moving lateral systems - Part 1 Presentation of the technical characteristics German version EN 12325-1 1998《灌溉方法 中心旋转枢轴和移.pdf DIN EN 12325-1-1999 Irrigation technic - Centre pivot and moving lateral systems - Part 1 Presentation of the technical characteristics German version EN 12325-1 1998《灌溉方法 中心旋转枢轴和移.pdf
  • DIN EN 12325-2-1999 Irrigation techniques - Centre pivot and moving lateral systems - Part 2 Minimum performances and technical characteristics German version EN 12325-2 1999《灌溉技术 .pdf DIN EN 12325-2-1999 Irrigation techniques - Centre pivot and moving lateral systems - Part 2 Minimum performances and technical characteristics German version EN 12325-2 1999《灌溉技术 .pdf
  • DIN EN 12325-3-1999 Irrigation techniques - Centre pivot and moving lateral systems - Part 3 Terminology and classification German version EN 12325-3 1999《灌溉技术 环行和横向移动系统 第3部分 术语和分类.pdf DIN EN 12325-3-1999 Irrigation techniques - Centre pivot and moving lateral systems - Part 3 Terminology and classification German version EN 12325-3 1999《灌溉技术 环行和横向移动系统 第3部分 术语和分类.pdf
  • 相关搜索

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

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