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

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

1、三级信息管理技术机试-276 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是实现从文件 ENG56IN 中读取一篇英文文章,并存入到字符串数组 xx 中。请编制函数 encryChar(),按给定的替代关系对数组 xx 中的所有字符进行替代,结果仍存人数组 xx 的对应的位置上,最后调用函数 WfiteDat()把结果 xx 输出到文件 ps56.dat 中。替代关系:f(P)=P*11 mod 256(P 是数组 xx 中某一个字符的 ASC值,f(P)是计算后新字符的 ASC值),如果原字符是小写字母或

2、计算后 f(P)的值小于等于 32,则该字符不变,否则将 f(P)所对应的字符进行替代。注意:部分源程序已给出。原始数据文件的存放格式是:每行的宽度均小于 80 个字符。请勿改动主函教 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序#includestdlib.h#includestdio.h#includestring.h#includectype.hunsigned char xx5080;int maxline=0;int ReadDat(void);void WriteDat(void);void encryChar()voidmain()sys

3、tem(“CLS“);if(ReadDat()printf(“数据文件 ENG56.IN 不能打开!/n/007“);return;encryChar();WriteDat();int ReadDat(void)FILE*fp;int i=0;unsigned char*P;if(fp=fopen(“ENG56.IN“,“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;f

4、p=fopen(“ps56.dat“,“W“);for(i=0;imaxline;i+)printf(“%s/n“,xxi);fprintf(fp,“%s/n“,xxi);fclose(fp);(分数:100.00)_三级信息管理技术机试-276 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是实现从文件 ENG56IN 中读取一篇英文文章,并存入到字符串数组 xx 中。请编制函数 encryChar(),按给定的替代关系对数组 xx 中的所有字符进行替代,结果仍存人数组 xx 的对应的位置上,最后调用函数 W

5、fiteDat()把结果 xx 输出到文件 ps56.dat 中。替代关系:f(P)=P*11 mod 256(P 是数组 xx 中某一个字符的 ASC值,f(P)是计算后新字符的 ASC值),如果原字符是小写字母或计算后 f(P)的值小于等于 32,则该字符不变,否则将 f(P)所对应的字符进行替代。注意:部分源程序已给出。原始数据文件的存放格式是:每行的宽度均小于 80 个字符。请勿改动主函教 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序#includestdlib.h#includestdio.h#includestring.h#includec

6、type.hunsigned char xx5080;int maxline=0;int ReadDat(void);void WriteDat(void);void encryChar()voidmain()system(“CLS“);if(ReadDat()printf(“数据文件 ENG56.IN 不能打开!/n/007“);return;encryChar();WriteDat();int ReadDat(void)FILE*fp;int i=0;unsigned char*P;if(fp=fopen(“ENG56.IN“,“r“)=NULL)return 1;while(fgets(

7、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;fp=fopen(“ps56.dat“,“W“);for(i=0;imaxline;i+)printf(“%s/n“,xxi);fprintf(fp,“%s/n“,xxi);fclose(fp);(分数:100.00)_正确答案:(void encryChar()int i,j; /*定义循环控制变量*/int str; /*存储字符串的长度*/char ch; /*存储当前取得的字

8、符*/for(i=0;imaxline;i+) /*以行为单位获取字符*/str=strlen(xxi); /*求得当前行的字符串长度*/for(j=0;jstr;j+) /*依次取每行的所有字符*/ch=xxij*11%256;if(xxij=a /*则不作改变,指向下一个字符*/elsexxij=ch; /*否则用新字符取代原有字符*/)解析:解析 本题要对二维数组中的字符元素按行进行处理。首先用 strlen()函数得到当前行所包含的字符个数。然后利用一个循环来依次访问该行中的所有字符。对于每一个字符,先按照题目中的函数替代关系“f(p)=P*11 mod256”计算出相应的 f(p)值,再用一条if 语句判断该值是否符合本题给定的条件:“原字符是小写字母或计算后的值小于等于 32”。如果符合条件,则该字符不变,否则用 f(P)所对应的字符对其进行替代。

展开阅读全文
相关资源
猜你喜欢
  • BS EN 15875-2011 Characterization of waste Static test for determination of acid potential and neutralisation potential of sulfidic waste《废弃物特征 硫磺酸废物中和势能产酸能力测定静态试验》.pdf BS EN 15875-2011 Characterization of waste Static test for determination of acid potential and neutralisation potential of sulfidic waste《废弃物特征 硫磺酸废物中和势能产酸能力测定静态试验》.pdf
  • BS EN 15876-1-2016 Electronic fee collection Evaluation of on-board and roadside equipment for conformity to EN 15509 Test suite structure and test purposes《电子收费 车载和路边设备对EN 15509标准.pdf BS EN 15876-1-2016 Electronic fee collection Evaluation of on-board and roadside equipment for conformity to EN 15509 Test suite structure and test purposes《电子收费 车载和路边设备对EN 15509标准.pdf
  • BS EN 15876-2-2016 Electronic fee collection Evaluation of on-board and roadside equipment for conformity to EN 15509 Abstract test suite《电子收费 符合EN 15509的船载和路边设备的评估 抽象试验套件》.pdf BS EN 15876-2-2016 Electronic fee collection Evaluation of on-board and roadside equipment for conformity to EN 15509 Abstract test suite《电子收费 符合EN 15509的船载和路边设备的评估 抽象试验套件》.pdf
  • BS EN 15877-1-2012 Railway applications Marking on railway vehicles Freight wagons《轨道交通 铁路车辆划线 货运车辆》.pdf BS EN 15877-1-2012 Railway applications Marking on railway vehicles Freight wagons《轨道交通 铁路车辆划线 货运车辆》.pdf
  • BS EN 15877-2-2013 Railway applications Markings of railway vehicles External markings on coaches motive power units locomotives and on track machines《轨道交通 铁路车辆标记 车厢 动力装置 机车以及轨道交通设.pdf BS EN 15877-2-2013 Railway applications Markings of railway vehicles External markings on coaches motive power units locomotives and on track machines《轨道交通 铁路车辆标记 车厢 动力装置 机车以及轨道交通设.pdf
  • BS EN 15878-2010 Steel static storage systems Terms and definitions《钢材静态存储系统 术语和定义》.pdf BS EN 15878-2010 Steel static storage systems Terms and definitions《钢材静态存储系统 术语和定义》.pdf
  • BS EN 15879-1-2011 Testing and rating of direct exchange ground coupled heat pumps with electrically driven compressors for space heating and or cooling Direct exchange-to-water he.pdf BS EN 15879-1-2011 Testing and rating of direct exchange ground coupled heat pumps with electrically driven compressors for space heating and or cooling Direct exchange-to-water he.pdf
  • BS EN 15882-1-2011 Extended application of results from fire resistance tests for service installations Ducts《用于装置耐火性试验结果的扩展应用 管道》.pdf BS EN 15882-1-2011 Extended application of results from fire resistance tests for service installations Ducts《用于装置耐火性试验结果的扩展应用 管道》.pdf
  • BS EN 15882-2-2015 Extended application of results from fire resistance tests for service installations Fire dampers《服务设施耐火试验结果的扩展应用 防火档板》.pdf BS EN 15882-2-2015 Extended application of results from fire resistance tests for service installations Fire dampers《服务设施耐火试验结果的扩展应用 防火档板》.pdf
  • 相关搜索

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

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