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

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

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

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

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

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

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

6、destring.h#includectype.hunsigned char xx5080;int maxline=0;int ReadDat(void);void WriteDat(void);void encryChar()void main()clrscr();if(ReadDat()printf(“数据文件 ENG95. IN 不能打开!/n/007“);return;encryChar();WriteDat();int ReadDat(void)FILE *fp;int i=0;unsigned char *p;if(fp=fopen(“ENG95.IN“,“r“)=NULL)ret

7、urn 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;fp= fopen(“ps95.dat“,“w“);for(i=0;imaxline;i+)printf(“%s/n“,xxi);fprintf(fp,“%s/n“,xxi);fclose(fp);(分数:100.00)_正确答案:(void encryChar()int i;char *pf;for(i=0;imaxline;i+)pf=xxi

8、 /*指针 pf 指向该行第一个字符*/while(*pf!=0)if(*pf*11%256=A /则不做改变,指向下一个字符*/continue; /*退出本次循环*/*pf=*pf*11%256; /*否则用新字符取代原有字符*/pf+; /*指向下一个字符*/)解析:解析 本题考查的知识点如下;(1)字符对应的 ASCII 码。(2)判断结构中多个条件的“或”运算。(3)退出一次循环。(4)二维数组的访问。本题中,将数据存放在一个二维数组中,可以定义一个指向数组每一行的指针。初始时,指针指向该行的第一个元素,随着地址增加,指针指向后面的元素。在 C 语言中,字符可参与任何整数运算。实际上,是字符的 ASCII 码参与了运算。所以可以直接用字符代入 f(p)的关系式中求出替换字符。若 f(p)对应的字符是大写字母或 f(p)32,则该字符不变。只有当字符大于等于 A 小于等于 Z 时,才是大写字母,所以这两个条件之间用“与”运算。而字符是大写字母与 f(p)32 两条件满足一个即可,所以这两个条件之间用“或”运算。若字符不变,则可不必计算替换字符,使用 continue 跳出本次循环,进入下一次循环的条件判断中。因为这里不是直接退出循环结构,所以不能使用 break 语句。

展开阅读全文
相关资源
猜你喜欢
  • NASA-TP-1498-1979 Low-speed aerodynamic characteristics of a 13-percent-thick medium-speed airfoil designed for general aviation applications《设计用于通用航空应用13%厚中速翼剖面的低速空气动力特性》.pdf NASA-TP-1498-1979 Low-speed aerodynamic characteristics of a 13-percent-thick medium-speed airfoil designed for general aviation applications《设计用于通用航空应用13%厚中速翼剖面的低速空气动力特性》.pdf
  • NASA-TP-1580-1979 Low-speed aerodynamic performance of a high-aspect-ratio supercritical-wing transport model equipped with full-span slat and part-span double-slotted flaps《装配有全翼展.pdf NASA-TP-1580-1979 Low-speed aerodynamic performance of a high-aspect-ratio supercritical-wing transport model equipped with full-span slat and part-span double-slotted flaps《装配有全翼展.pdf
  • NASA-TP-1592-1979 Effects of fuselage forebody geometry on low-speed lateral-directional characteristics of twin-tail fighter model at high angles of attack《机身前部几何学对高攻角下双尾翼战斗机模型低速横.pdf NASA-TP-1592-1979 Effects of fuselage forebody geometry on low-speed lateral-directional characteristics of twin-tail fighter model at high angles of attack《机身前部几何学对高攻角下双尾翼战斗机模型低速横.pdf
  • NASA-TP-1619-1980 Application of a numerically generated orthogonal coordinate system to the solution of inviscid axisymmetric supersonic flow over blunt bodies《数字上产生的正交坐标系对钝机身非粘性轴.pdf NASA-TP-1619-1980 Application of a numerically generated orthogonal coordinate system to the solution of inviscid axisymmetric supersonic flow over blunt bodies《数字上产生的正交坐标系对钝机身非粘性轴.pdf
  • NASA-TP-1636-1980 Measurement of the handling characteristics of two light airplanes《两架轻型飞机的操纵特性测量》.pdf NASA-TP-1636-1980 Measurement of the handling characteristics of two light airplanes《两架轻型飞机的操纵特性测量》.pdf
  • NASA-TP-1652-1980 Measured and predicted shock shapes and aerodynamic coefficients for blunted cones at incidence in air at Mach 5 9《当马赫数为5 9时空气中发生率的钝圆锥测量和预测的振动形状和空气动力系数》.pdf NASA-TP-1652-1980 Measured and predicted shock shapes and aerodynamic coefficients for blunted cones at incidence in air at Mach 5 9《当马赫数为5 9时空气中发生率的钝圆锥测量和预测的振动形状和空气动力系数》.pdf
  • NASA-TP-1785-1980 Tests of graphite polyimide sandwich panels in uniaxial edgewise compression《在单轴沿边压缩石墨 聚酰亚胺夹层板的试验》.pdf NASA-TP-1785-1980 Tests of graphite polyimide sandwich panels in uniaxial edgewise compression《在单轴沿边压缩石墨 聚酰亚胺夹层板的试验》.pdf
  • NASA-TP-1786-1980 Low-speed aerodynamic characteristics of a 17-percent-thick medium-speed airfoil designed for general aviation applications《设计用于通用航空应用17%厚中等速度机翼的低速空气动力特性》.pdf NASA-TP-1786-1980 Low-speed aerodynamic characteristics of a 17-percent-thick medium-speed airfoil designed for general aviation applications《设计用于通用航空应用17%厚中等速度机翼的低速空气动力特性》.pdf
  • NASA-TP-1863-1981 Static and yawed-rolling mechanical properties of two type 7 aircraft tires《两个7类型飞机轮胎静态和偏航的旋转机械性能》.pdf NASA-TP-1863-1981 Static and yawed-rolling mechanical properties of two type 7 aircraft tires《两个7类型飞机轮胎静态和偏航的旋转机械性能》.pdf
  • 相关搜索

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

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