【计算机类职业资格】三级网络技术机试-269及答案解析.doc

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

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

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

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

4、d WriteDat(void)FILE *fp;int i;fp = fopen (“PS18.DAT“, “w“);for(i = 0; imaxline; i+)printf(“%s/n“, xxi );fprintf(fp, “%s/n“, xxi);fclose (fp);(分数:100.00)_三级网络技术机试-269 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是实现从文件 ENG18.IN 中读取一篇英文文章,存入到字符串数组 xx 中;请编制函数 encryptChar(),按给定的替代关系

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

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

7、p;if(fp = fopen(“ENG18.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 (“PS18.DAT“, “w“);for(i = 0; imaxline; i+)printf(“%s/n“, xxi );fprintf(fp, “%s/n“, xxi);fclose (fp);(分数:1

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

展开阅读全文
相关资源
猜你喜欢
  • DIN EN ISO 14607-2009 Non-active surgical implants - Mammary implants - Particular requirements (ISO 14607 2007) English version of DIN EN ISO 14607 2009-08《非活性外科植入物 乳房植入物 特殊要求(ISO.pdf DIN EN ISO 14607-2009 Non-active surgical implants - Mammary implants - Particular requirements (ISO 14607 2007) English version of DIN EN ISO 14607 2009-08《非活性外科植入物 乳房植入物 特殊要求(ISO.pdf
  • DIN EN ISO 1461-2009 Hot dip galvanized coatings on fabricated iron and steel articles - Specifications and test methods (ISO 1461 2009) English version of DIN EN ISO 1461 2009-10《.pdf DIN EN ISO 1461-2009 Hot dip galvanized coatings on fabricated iron and steel articles - Specifications and test methods (ISO 1461 2009) English version of DIN EN ISO 1461 2009-10《.pdf
  • DIN EN ISO 14616-2004 Plastics - Heatshrinkable films of polyethylene ethylene copolymers and their mixtures - Determination of shrinkage stress and contraction stress (ISO 14616 1.pdf DIN EN ISO 14616-2004 Plastics - Heatshrinkable films of polyethylene ethylene copolymers and their mixtures - Determination of shrinkage stress and contraction stress (ISO 14616 1.pdf
  • DIN EN ISO 14629-2016 Fine ceramics (advanced ceramics advanced technical ceramics) - Determination of flowability of ceramic powders (ISO 14629 2012) German version EN ISO 14629 2.pdf DIN EN ISO 14629-2016 Fine ceramics (advanced ceramics advanced technical ceramics) - Determination of flowability of ceramic powders (ISO 14629 2012) German version EN ISO 14629 2.pdf
  • DIN EN ISO 1463-2004 Metallic and oxide coatings - Measurement of coating thickness - Microscopical method (ISO 1463 2003) German version EN ISO 1463 2004《金属和氧化物镀层 镀层厚度的测定 显微镜法》.pdf DIN EN ISO 1463-2004 Metallic and oxide coatings - Measurement of coating thickness - Microscopical method (ISO 1463 2003) German version EN ISO 1463 2004《金属和氧化物镀层 镀层厚度的测定 显微镜法》.pdf
  • DIN EN ISO 14630-2013 Non-active surgical implants - General requirements (ISO 14630 2012) German version EN ISO 14630 2012《非活性外科植入物 通用要求(ISO 14630-2012) 德文版本EN ISO 14630-2012》.pdf DIN EN ISO 14630-2013 Non-active surgical implants - General requirements (ISO 14630 2012) German version EN ISO 14630 2012《非活性外科植入物 通用要求(ISO 14630-2012) 德文版本EN ISO 14630-2012》.pdf
  • DIN EN ISO 14631-1999 Extruded sheets of impact-modified polystyrene (PS-I) - Requirements and test methods (ISO 14631 1999) German version EN ISO 14631 1999《冲击改良的聚苯乙烯(PS-I)的挤出片 要求.pdf DIN EN ISO 14631-1999 Extruded sheets of impact-modified polystyrene (PS-I) - Requirements and test methods (ISO 14631 1999) German version EN ISO 14631 1999《冲击改良的聚苯乙烯(PS-I)的挤出片 要求.pdf
  • DIN EN ISO 14632-1999 Extruded sheets of polyethylene (PE-HD) - Requirements and test methods (ISO 14632 1998) German version EN ISO 14632 1998《聚乙烯(PE-HD)的挤压薄板材 要求和试验方法》.pdf DIN EN ISO 14632-1999 Extruded sheets of polyethylene (PE-HD) - Requirements and test methods (ISO 14632 1998) German version EN ISO 14632 1998《聚乙烯(PE-HD)的挤压薄板材 要求和试验方法》.pdf
  • DIN EN ISO 14637-2007 Milk - Determination of urea content - Enzymatic method using difference in pH (Reference method) (ISO 14637 2004) English version of DIN EN ISO 14637 2007-03.pdf DIN EN ISO 14637-2007 Milk - Determination of urea content - Enzymatic method using difference in pH (Reference method) (ISO 14637 2004) English version of DIN EN ISO 14637 2007-03.pdf
  • 相关搜索

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

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