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

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

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

2、读数据函数 ReadDat()和输出数据函数 writeDat()的内容。试题源程序#includestdioh#includestrinqh#includeconiohchar xx(5080;int maxline=0; /*文章的总行数*/int ReadDat(void);void WriteDat(void);void SortCharD(void)int ReadDat(void)FILE*fp;int i=0;char*P;if(fp=fopen(“INDAT“,“r“)=NULL)return 1:while(fgets(xxi,80,fp)!=NULL)P=strchr(xx

3、i,n);if(p)*P=0:i+:maxline=i;fclose(fp);return 0;void WriteDat(void)FILE*fp;int i;fp=fopen(“OUTDAT“,“w“);for(i=0;imaxline;i+)printf(“%s/n“,xxi);fprintf(fp,“%s/n“,xxi);fclose(fp);void main()system(“cls“);if(ReadDat()printf(“数据文件 INDAT 不能打开!/n/007“);return;SortCharD();WriteDat():(分数:100.00)_三级信息管理技术机试-

4、212 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()实现从文件 in.dat中读取一篇英文文章并存入到字符串数组 xx中,请编制函数sortcharD(),其函数的功能是以行为单位对字符按从小到大的顺序进行排序,排序后的结果仍按行重新存入字符串数组中,最后调用函数 writeDat(),把结果 xx输出到文件 out.dat中。例:原文:dAeBfC结果:ABCdef原数据文件存放的格式是每行的宽度均小于 80个字符,含标点符号和空格。注意:部分源程序给出如下:请勿改动主函数 main()、读数据函数 ReadDa

5、t()和输出数据函数 writeDat()的内容。试题源程序#includestdioh#includestrinqh#includeconiohchar xx(5080;int maxline=0; /*文章的总行数*/int ReadDat(void);void WriteDat(void);void SortCharD(void)int ReadDat(void)FILE*fp;int i=0;char*P;if(fp=fopen(“INDAT“,“r“)=NULL)return 1:while(fgets(xxi,80,fp)!=NULL)P=strchr(xxi,n);if(p)*P

6、0:i+:maxline=i;fclose(fp);return 0;void WriteDat(void)FILE*fp;int i;fp=fopen(“OUTDAT“,“w“);for(i=0;imaxline;i+)printf(“%s/n“,xxi);fprintf(fp,“%s/n“,xxi);fclose(fp);void main()system(“cls“);if(ReadDat()printf(“数据文件 INDAT 不能打开!/n/007“);return;SortCharD();WriteDat():(分数:100.00)_正确答案:(void SortCharD(vo

7、id)int i,j,k,str;char ch;for(i=0;imaxline;i+) /*遍历所有行*/str=strlen(xxi);for(J=0:Jstr-1;J+)for(k=J+1;kstr;k+) /*对每行元素进行选择排序*/if(xxijxxik) /*如果存在顺序,交换两个元素*/ch=xxij;xxij=xxik;xxik=ch;)解析:解析 本题主要考查的是字符串排序问题。首先用 for循环和变量 i对每一行遍历,对于某一行xxi来说,使用两重 for循环进行冒泡排序。对某一个字符 xxij来说,将该字符后面的每个字符xxik(k从 j+1开始)和 xxiJ进行比较,如果存在顺序则使用临时变量 ch,将 xxij和 xxik交换位置。

展开阅读全文
相关资源
猜你喜欢
  • ASTM F738M-2002 Standard Specification for Stainless Steel Metric Bolts Screws and Studs《不锈钢米制螺栓、螺钉及螺柱(米制)的标准规范》.pdf ASTM F738M-2002 Standard Specification for Stainless Steel Metric Bolts Screws and Studs《不锈钢米制螺栓、螺钉及螺柱(米制)的标准规范》.pdf
  • ASTM F739-2007 Standard Test Method for Permeation of Liquids and Gases through Protective Clothing Materials under Conditions of Continuous Contact《连续接触条件下穿过防护服材料的液体和气体渗透物的标准试验方法》.pdf ASTM F739-2007 Standard Test Method for Permeation of Liquids and Gases through Protective Clothing Materials under Conditions of Continuous Contact《连续接触条件下穿过防护服材料的液体和气体渗透物的标准试验方法》.pdf
  • ASTM F739-2012 Standard Test Method for Permeation of Liquids and Gases through Protective Clothing Materials under Conditions of Continuous Contact《连续接触条件下防护服材料抗液体或气体渗透的标准试验方法》.pdf ASTM F739-2012 Standard Test Method for Permeation of Liquids and Gases through Protective Clothing Materials under Conditions of Continuous Contact《连续接触条件下防护服材料抗液体或气体渗透的标准试验方法》.pdf
  • ASTM F739-2012e1 Standard Test Method for Permeation of Liquids and Gases through Protective Clothing Materials under Conditions of Continuous Contact《连续接触条件下防护服材料抗液体或气体渗透的标准试验方法》.pdf ASTM F739-2012e1 Standard Test Method for Permeation of Liquids and Gases through Protective Clothing Materials under Conditions of Continuous Contact《连续接触条件下防护服材料抗液体或气体渗透的标准试验方法》.pdf
  • ASTM F744M-1997(2003) Standard Test Method for Measuring Dose Rate Threshold for Upset of Digital Integrated Circuits [Metric]《数字集成电路的干扰用剂量阈值测量的标准试验方法(米制)》.pdf ASTM F744M-1997(2003) Standard Test Method for Measuring Dose Rate Threshold for Upset of Digital Integrated Circuits [Metric]《数字集成电路的干扰用剂量阈值测量的标准试验方法(米制)》.pdf
  • ASTM F744M-2010 Standard Test Method for Measuring Dose Rate Threshold for Upset of Digital Integrated Circuits [Metric]《数字集成电路扰乱的剂量速率阙值测定的标准试验方法【公制单位】》.pdf ASTM F744M-2010 Standard Test Method for Measuring Dose Rate Threshold for Upset of Digital Integrated Circuits [Metric]《数字集成电路扰乱的剂量速率阙值测定的标准试验方法【公制单位】》.pdf
  • ASTM F744M-2016 Standard Test Method for Measuring Dose Rate Threshold for Upset of Digital Integrated Circuits (Metric)《测量数字集成电路 (米制) 混乱用剂量率阀值的标准试验方法》.pdf ASTM F744M-2016 Standard Test Method for Measuring Dose Rate Threshold for Upset of Digital Integrated Circuits (Metric)《测量数字集成电路 (米制) 混乱用剂量率阀值的标准试验方法》.pdf
  • ASTM F746-2004 Standard Test Method for Pitting or Crevice Corrosion of Metallic Surgical Implant Materials《金属外科植入材料的凹痕或裂隙腐蚀的标准试验方法》.pdf ASTM F746-2004 Standard Test Method for Pitting or Crevice Corrosion of Metallic Surgical Implant Materials《金属外科植入材料的凹痕或裂隙腐蚀的标准试验方法》.pdf
  • ASTM F746-2004(2009)e1 Standard Test Method for Pitting or Crevice Corrosion of Metallic Surgical Implant Materials《金属外科植入材料的凹痕或裂隙腐蚀的试验方法》.pdf ASTM F746-2004(2009)e1 Standard Test Method for Pitting or Crevice Corrosion of Metallic Surgical Implant Materials《金属外科植入材料的凹痕或裂隙腐蚀的试验方法》.pdf
  • 相关搜索

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

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