【计算机类职业资格】三级信息管理技术机试-258及答案解析.doc

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

1、三级信息管理技术机试-258 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是实现从文件 IN73.DAT 中读取一篇英文文章并存入到字符串数组 xx 中。请编制函数 SortCharA(),该函数的功能是:以行为单位对字符按从小到大的顺序进行排序,排序后的结果仍按行重新存入字符串数组 xx 中。最后调用函数 WriteDat()把结果 xx 输出到文件 OUT73.DAT 中。注意:部分源程序已给出。原始数据文件存放的格式是:每行的宽度均小于 80 个字符,含标点符号和空格。请勿改动主函数 main()、读

2、函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#include stdio.h#include string.h#include stdlib.hchar xx5080;int maxline=0;int ReadDat(void);void WriteDat(void);void SortCharA()void main()system(“CLS“);if(ReadDat();printf(“数据文件 IN73.DAT 不能打开! /n/007“);return;SortCharA();WriteDat();int ReadDat(void);FILE * fp;i

3、nt i=0;char * p;if(fp=fopen(“IN73.DAT“,“r“)=NULL)return1;while(fgets(xx1,80,fp)!=NULL)p=strchr(xxi,/n);if(p) * p=0;i + +;maxline=i;fclose(fp);return 0;void WriteDat()FILE * fp;int isystem(“CLS“);fp=fopen(“IN73.DAT“,“w“);for(i=0,imaxline;i + +)printf(“% s/n“,xxi);fprintf(fp,“% s/n“,xxi);fclose(fp);(分

4、数:100.00)_三级信息管理技术机试-258 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是实现从文件 IN73.DAT 中读取一篇英文文章并存入到字符串数组 xx 中。请编制函数 SortCharA(),该函数的功能是:以行为单位对字符按从小到大的顺序进行排序,排序后的结果仍按行重新存入字符串数组 xx 中。最后调用函数 WriteDat()把结果 xx 输出到文件 OUT73.DAT 中。注意:部分源程序已给出。原始数据文件存放的格式是:每行的宽度均小于 80 个字符,含标点符号和空格。请勿改动主函数

5、 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#include stdio.h#include string.h#include stdlib.hchar xx5080;int maxline=0;int ReadDat(void);void WriteDat(void);void SortCharA()void main()system(“CLS“);if(ReadDat();printf(“数据文件 IN73.DAT 不能打开! /n/007“);return;SortCharA();WriteDat();int ReadDat(void);FI

6、LE * fp;int i=0;char * p;if(fp=fopen(“IN73.DAT“,“r“)=NULL)return1;while(fgets(xx1,80,fp)!=NULL)p=strchr(xxi,/n);if(p) * p=0;i + +;maxline=i;fclose(fp);return 0;void WriteDat()FILE * fp;int isystem(“CLS“);fp=fopen(“IN73.DAT“,“w“);for(i=0,imaxline;i + +)printf(“% s/n“,xxi);fprintf(fp,“% s/n“,xxi);fclo

7、se(fp);(分数:100.00)_正确答案:(void SortCharA()int i,j,k; /*定义循环控制变量*/int str; /*存储字符串的长度*/char temp; /*数据交换时的暂存变量*/for(i=0;imaxline;i + +) /*以行为单位获取字符*/str=strlen(xxi); /*求得当前行的字符串长度*/for(j=0;jstr-1;j + +) /*对字符按从小到大的顺序进行排序*/for(k=j+1;kstr;k + +)if(xxijxxik)temp=xxij;xxij=xxik;xxik=temp;)解析:解析 本题主要考查数组的访问及排序问题。通过双重循环结构逐行获取字符进行处理,首先使用字符串处理函数 strlen()来求出每一行的字符串长度。然后运用选择法逐行对字符按照从小到大的顺序进行排序。

展开阅读全文
相关资源
猜你喜欢
  • KS I ISO 10843-2007 Acoustics-Methods for the description and physical measurement of single impulses or series of impulses《声学 单个脉冲或脉冲串的物理测量和描述方法》.pdf KS I ISO 10843-2007 Acoustics-Methods for the description and physical measurement of single impulses or series of impulses《声学 单个脉冲或脉冲串的物理测量和描述方法》.pdf
  • KS I ISO 10849-2008 Stationary source emissions-Determination of the mass concentration of nitrogen oxides-Performance characteristics of automated measuring systems《固定源排放 氮氧化物质量浓度.pdf KS I ISO 10849-2008 Stationary source emissions-Determination of the mass concentration of nitrogen oxides-Performance characteristics of automated measuring systems《固定源排放 氮氧化物质量浓度.pdf
  • KS I ISO 11041-2008 Workplace air-Determination of particulate arsenic and arsenic compounds and arsenic trioxide vapour-Method by hydride generation and atomic absorption spectrom.pdf KS I ISO 11041-2008 Workplace air-Determination of particulate arsenic and arsenic compounds and arsenic trioxide vapour-Method by hydride generation and atomic absorption spectrom.pdf
  • KS I ISO 11047-2009 Soil quality-Determination of cadmium chromium cobalt copper lead manganese nickel and zinc in aqua regia extracts of soil-Flame and electrothermal atomic absor.pdf KS I ISO 11047-2009 Soil quality-Determination of cadmium chromium cobalt copper lead manganese nickel and zinc in aqua regia extracts of soil-Flame and electrothermal atomic absor.pdf
  • KS I ISO 11048-2008 Soil quality-Determination of water-soluble and acid-soluble sulfate《土壤质量 水溶性硫酸盐和酸溶性硫酸盐的测定》.pdf KS I ISO 11048-2008 Soil quality-Determination of water-soluble and acid-soluble sulfate《土壤质量 水溶性硫酸盐和酸溶性硫酸盐的测定》.pdf
  • KS I ISO 11074-2007 Soil quality-Vocabulary《土壤质量 词汇》.pdf KS I ISO 11074-2007 Soil quality-Vocabulary《土壤质量 词汇》.pdf
  • KS I ISO 11083-2008 Water quality-Determination of chromium(VI)-Spectrometric method using 1 5-diphenylcarbazide《水质 六价铬的测定 1、5-二苯卡巴肼光度法》.pdf KS I ISO 11083-2008 Water quality-Determination of chromium(VI)-Spectrometric method using 1 5-diphenylcarbazide《水质 六价铬的测定 1、5-二苯卡巴肼光度法》.pdf
  • KS I ISO 11150-2010 Natural gas-Hydrocarbon dew point and hydrocarbon content《天然气 碳氢化合物的露点和碳氢化合物的含量》.pdf KS I ISO 11150-2010 Natural gas-Hydrocarbon dew point and hydrocarbon content《天然气 碳氢化合物的露点和碳氢化合物的含量》.pdf
  • KS I ISO 11174-2008 Workplace air-Determination of particulate cadmium and cadmium compounds-Flame and electrothermal atomic absorption spectromet method《车间空气和镉化合物悬浮粒子的测定 燃烧和电热原子吸收.pdf KS I ISO 11174-2008 Workplace air-Determination of particulate cadmium and cadmium compounds-Flame and electrothermal atomic absorption spectromet method《车间空气和镉化合物悬浮粒子的测定 燃烧和电热原子吸收.pdf
  • 相关搜索

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

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