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

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

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

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

3、d encryptChar()main ( )clrscr();if(ReadDat()print f (“数据文件 ENG28.IN 不能打开 ! /n /007“ );return;encryptChar();WriteDat();int ReadDat (void)FILE *fp;int i = 0;unsigned char *p;if(fp = fopen(“ENG28.IN“,“r“) =NULL)return 1;while(fgets(xxi, 80, fp) !=NULL)p = strchr(xxi,/n);if(p) *p = 0;i+;maxline = i;fclo

4、se(fp);return 0;void WriteDat(void)FILE *fp;int i;fp = fopen(“PS28.DAT“,“w“);for (i = 0; imaxline; i+)printf(“%s/n“, xxi);fprintf(fp, “%s/n“, xxi);fclose(fp);(分数:100.00)_三级信息管理技术机试-314 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.读函数 ReadDat()实现从文件 ENG28.IN 中读取一篇英文文章,存入到字符串数组 xx 中。请编制函数encryptC

5、har(),按给定的替代关系对数组 xx 中的所有字符进行替代,仍存入数组 xx 的对应的位置上,最后调用写函数 WriteDat()把结果 xx 输出到文件 PS28.DAT 中。替代关系:f(p)p*11 mod 256(p 是数组 xx 中某一个字符的 ASCII 值,f(p)是计算后新字符的 ASCII 值),如果计算后 f(p)的值小于等于 32 或 f(p)对应的字符是小写字母,则该字符不变,否则将 f(p)所对应的字符进行替代。注意:部分源程序已给出。原始数据文件存放的格式是:每行的宽度均小于 80 个字符。请勿改动主函数 main()、读函数 ReadDat()和写函数 Wri

6、teDat()的内容。试题程序:#includestdio.h#includestring.h#includeconio.h#includectype.hunsigned char xx50 80;int maxline = 0; /* 文章的总行数 */int ReadDat(void);void WriteDat(void);void encryptChar()main ( )clrscr();if(ReadDat()print f (“数据文件 ENG28.IN 不能打开 ! /n /007“ );return;encryptChar();WriteDat();int ReadDat (

7、void)FILE *fp;int i = 0;unsigned char *p;if(fp = fopen(“ENG28.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(void)FILE *fp;int i;fp = fopen(“PS28.DAT“,“w“);for (i = 0; imaxline; i+)printf(“%s/n“, xxi);fprintf(f

8、p, “%s/n“, xxi);fclose(fp);(分数:100.00)_正确答案:(void encryptChar ( )int i;char *pf;for ( i = 0; imaxline; i+)pf=xx i;while (*pf ! =0)if (*pf*11%256=a /*则不作任何操作,取下一个数进行处理*/continue;*pf=*pf*11%256; /*否则用新字符来替代这个字符*/pf+; /*取下一个字符*/)解析:解析 本题主要考查用指针变量来控制字符数组,由于要对已有二维字符数组的所有元素逐个处理,因此,需要定义一个字符指针变量来控制原二维数组的各行。当前行如果确定下来,用指针的移动就可以依次扫描该行的所有字符元素,每得到一个字符就对它进行条件判断。根据题意,条件用“if(*pf*11%256=a&*pf*11%256=z)|*pf*11%256=32)”语句来实现。如果该字符不满足上述条件,就用一个新的字符来替代,新的字符是当前字符乘以 11 的结果再去与 256 取余,处理完毕后,指针去取下一个字符。如果该字符满足所给条件,将不做任何操作,指针直接下移,去取下一个字符,对下一个字符进行处理。

展开阅读全文
相关资源
猜你喜欢
  • DIN VDE 0100-444-2010 Low-voltage electrical installations - Part 4-444 Protection for safety - Protection against voltage disturbances and electromagnetic disturbances (IEC 60364-.pdf DIN VDE 0100-444-2010 Low-voltage electrical installations - Part 4-444 Protection for safety - Protection against voltage disturbances and electromagnetic disturbances (IEC 60364-.pdf
  • DIN VDE 0100-520 Bb 3-2012 Low-voltage electrical installations - Selection and erection of electrical equipment - Part 520 Wiring systems - Supplement 3 Current-carrying capacity .pdf DIN VDE 0100-520 Bb 3-2012 Low-voltage electrical installations - Selection and erection of electrical equipment - Part 520 Wiring systems - Supplement 3 Current-carrying capacity .pdf
  • DIN VDE 0100-520-2013 Low-voltage electrical installations - Part 5-52 Selection and erection of electrical equipment - Wiring systems (IEC 60364-5-52 2009 modified + Corrigendum F.pdf DIN VDE 0100-520-2013 Low-voltage electrical installations - Part 5-52 Selection and erection of electrical equipment - Wiring systems (IEC 60364-5-52 2009 modified + Corrigendum F.pdf
  • DIN VDE 0100-540-2012 Low-voltage electrical installations - Part 5-54 Selection and erection of electrical equipment - Earthing arrangements and protective conductors (IEC 60364-5.pdf DIN VDE 0100-540-2012 Low-voltage electrical installations - Part 5-54 Selection and erection of electrical equipment - Earthing arrangements and protective conductors (IEC 60364-5.pdf
  • DIN VDE 0100-560-2013 Low-voltage electrical installations Part 5-56 Selection and erection of electrical equipment Safety services (IEC 60364-5-56 2009 modified) German implementa.pdf DIN VDE 0100-560-2013 Low-voltage electrical installations Part 5-56 Selection and erection of electrical equipment Safety services (IEC 60364-5-56 2009 modified) German implementa.pdf
  • DIN VDE 0100-701-2008 Low-voltage electrical installations - Part 7-701 Requirements for special installations or locations - Locations containing a bath or shower (IEC 60364-7-701.pdf DIN VDE 0100-701-2008 Low-voltage electrical installations - Part 7-701 Requirements for special installations or locations - Locations containing a bath or shower (IEC 60364-7-701.pdf
  • DIN VDE 0100-702-2012 Low-voltage electrical installations - Part 7-702 Requirements for special installations or locations - Basins of swimming pools other water basins and founta.pdf DIN VDE 0100-702-2012 Low-voltage electrical installations - Part 7-702 Requirements for special installations or locations - Basins of swimming pools other water basins and founta.pdf
  • DIN VDE 0100-703-2006 Low voltage installations - Part 7-703 Requirements for special installations or locations - Rooms and cabins containing sauna heaters (IEC 60364-7-703 2004) .pdf DIN VDE 0100-703-2006 Low voltage installations - Part 7-703 Requirements for special installations or locations - Rooms and cabins containing sauna heaters (IEC 60364-7-703 2004) .pdf
  • DIN VDE 0100-704-2007 Low-voltage electrical installations - Part 7-704 Requirements for special installations or locations - Construction and demolition site installations (IEC 60.pdf DIN VDE 0100-704-2007 Low-voltage electrical installations - Part 7-704 Requirements for special installations or locations - Construction and demolition site installations (IEC 60.pdf
  • 相关搜索

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

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