【计算机类职业资格】三级网络技术-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 语言中,字符量可参与任何整 型运算,所以可以直接使用比较运算符进行比较。排序使用前面介绍的“选择排序法”。最后使用循环结构对文章中的每一行都进行以上的操作。

展开阅读全文
相关资源
猜你喜欢
  • DS ETS 300221-1994 Terminal Equipment (TE) Syntax-based Videotex lower layer protocols using packet mode acces over the Public Switched Telephone Network (PSTN)《终端设备(TE) 公共交换网(PSTN.pdf DS ETS 300221-1994 Terminal Equipment (TE) Syntax-based Videotex lower layer protocols using packet mode acces over the Public Switched Telephone Network (PSTN)《终端设备(TE) 公共交换网(PSTN.pdf
  • DS ETS 300222-1994 Terminal Equipment (TE) Framework of Videotex terminal protocols《终端设备(TE) 可视信息系统终端协议框架》.pdf DS ETS 300222-1994 Terminal Equipment (TE) Framework of Videotex terminal protocols《终端设备(TE) 可视信息系统终端协议框架》.pdf
  • DS ETS 300223-1994 Terminal Equipment (TE) Syntax-based Videotex Common end-to-end protocols《终端设备(TE) 基于语法的可视信息系统 共用端对端协议》.pdf DS ETS 300223-1994 Terminal Equipment (TE) Syntax-based Videotex Common end-to-end protocols《终端设备(TE) 基于语法的可视信息系统 共用端对端协议》.pdf
  • DS ETS 300226-1993 Transmission and Multiplexing (TM) Single-mode optical fibre cabels to be used in ducts and for directly buried application《传输和复用(TM) 用于管道内和直埋的单模光缆》.pdf DS ETS 300226-1993 Transmission and Multiplexing (TM) Single-mode optical fibre cabels to be used in ducts and for directly buried application《传输和复用(TM) 用于管道内和直埋的单模光缆》.pdf
  • DS ETS 300232-1994 Transmission and Multiplexing (TM) Optical interfaces for equipments and systems relating to the Synchrounous Digital Hierarchy [ITU-T Recommendation G 957 (1993.pdf DS ETS 300232-1994 Transmission and Multiplexing (TM) Optical interfaces for equipments and systems relating to the Synchrounous Digital Hierarchy [ITU-T Recommendation G 957 (1993.pdf
  • DS ETS 300233-1994 Integrated Services Digital Network (ISDN) - Access digital section for ISDN primary rate《综合业务数字网(ISDN) ISDN主速率接入数字段》.pdf DS ETS 300233-1994 Integrated Services Digital Network (ISDN) - Access digital section for ISDN primary rate《综合业务数字网(ISDN) ISDN主速率接入数字段》.pdf
  • DS ETS 300249-1994 Satellite Earth Stations (SES) Television Receive-Only (TVRO) equipment used in the Broadcasting Satellite Service (BSS)《卫星地球站(SES),广播卫星业务(BSS)中使用的电视信号只收(TVRO)设备.pdf DS ETS 300249-1994 Satellite Earth Stations (SES) Television Receive-Only (TVRO) equipment used in the Broadcasting Satellite Service (BSS)《卫星地球站(SES),广播卫星业务(BSS)中使用的电视信号只收(TVRO)设备.pdf
  • DS ETS 300250-1994 Television Systems EBU ETSI Joint Technical Committee (JTC) Specification of the D2-MAC Packet system《电视系统 EBU ETSI联合技术委员会(JTC) D2-MAC 分组系统规范》.pdf DS ETS 300250-1994 Television Systems EBU ETSI Joint Technical Committee (JTC) Specification of the D2-MAC Packet system《电视系统 EBU ETSI联合技术委员会(JTC) D2-MAC 分组系统规范》.pdf
  • DS ETS 300254-1994 Satellite Earth Stations and Systems (SES) - land Mobile Earth Stations (LMESs) operating in the 1 5 1 6 ZHz bands providing Low Bit Rate Data Communications (LB.pdf DS ETS 300254-1994 Satellite Earth Stations and Systems (SES) - land Mobile Earth Stations (LMESs) operating in the 1 5 1 6 ZHz bands providing Low Bit Rate Data Communications (LB.pdf
  • 相关搜索

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

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