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

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

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

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

3、 msin()system(“cls“);if(ReadDat()printf(“数据文件 ENG.IN 不能打开!/n/007“);return;encryptChar();writeDat();int ReadDat(void)FILE *fp;int i=0;unsigned char *p;if(fp=fopen(“eng.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)F

4、ILE *fp;int i;fp=fopen(“ps.dat“,“w“);for(i=0;imaxline;i+)printf(“%s/n“,xxi);fprintf(fp,“%s/n“,xxi);fclose(fp);(分数:100.00)_三级网络技术机试-158 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()用于实现从文件 ENG.IN 中读取一篇英文文章,并将其存入字符串数组 xx 中。请编制函数 encryptChar0(),按给定的替代关系对数组 xx 中所有的字符进行替代,结果仍存入字符串数组 xx 的

5、对应位置上,最后调用函数 WriteDat()把结果艇输出到文件 PS3.DAT 中。替代关系:f(p)=p*17 mod 256(p 是数组中某一个字符的 ASC值,f(p)是计算后新字符的 ASC值)。如果计算后 f(p)的值小于 32 或其 ASC值是奇数,则该字符不变,否则将 f(p)所对应的字符进行替代。原始数据文件的格式是:每行的宽度均小于 80 个字符。注意:部分源程序给出如下。请勿改动主函数 main()、读数据函数 ReadDat()和输出数据函数 WriteDat()的内容。试题源程序#includestdio.h#includestring.h#includeconio.

6、h#includectype.hunsigned char xx5080;int maxline=0;/*文章的总行数*/int ReadDat(void);void WriteDat(void);void encryptChar()void msin()system(“cls“);if(ReadDat()printf(“数据文件 ENG.IN 不能打开!/n/007“);return;encryptChar();writeDat();int ReadDat(void)FILE *fp;int i=0;unsigned char *p;if(fp=fopen(“eng.in“,“r“)=NUL

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

8、) /*遍历数组 xx 的所有行*/p=xxi; /*让字符指针指向该行的第一个字符*/while(*P!=0) if(*P*17%256)%2!=0|(*p*17%25 6)=32)/*若替换值满足替换条件*/P+;continue;*p=*p*17%256; /*将指针 p 的内容替换为计算出的值*/p+; /*移动指针 p 指向下一个字符*/)解析:解析本题主要考查的是字符替换问题。首先用 for 循环遍历每 97,对于某一行 xxi来说,先让字符指针 p 指向该行的第一个字符,然后使用 while 循环和指针 p 遍历该行的每一个字符。根据题目要求,如果遇到“p*17 mod 256”的值为奇数或者小于等于 32,字符不变(把指针指向下一个字符,结束本次循环),否则将该字符替换为“p*17 mod 256”的值,将指针指向下一个字符,进入下一次循环。

展开阅读全文
相关资源
猜你喜欢
  • EN 12453-2000 en Industrial Commercial and Garage Doors and Gates - Safety in Use of Power Operated Doors - Requirements《工业 商业和车库门 大门电动门使用安全性要求》.pdf EN 12453-2000 en Industrial Commercial and Garage Doors and Gates - Safety in Use of Power Operated Doors - Requirements《工业 商业和车库门 大门电动门使用安全性要求》.pdf
  • EN 12455-1999 en Resilient Floor Coverings - Specification for Corkment Underlay《弹性地板覆盖物 软木垫底层规范》.pdf EN 12455-1999 en Resilient Floor Coverings - Specification for Corkment Underlay《弹性地板覆盖物 软木垫底层规范》.pdf
  • EN 12457-1-2002 en Characterisation of waste - Leaching - Compliance test for leaching of granular waste materials and sludges - Part 1 One stage batch test at a liquid to solid ra.pdf EN 12457-1-2002 en Characterisation of waste - Leaching - Compliance test for leaching of granular waste materials and sludges - Part 1 One stage batch test at a liquid to solid ra.pdf
  • EN 12457-2-2002 en Characterisation of waste Leaching Compliance test for leaching of granular waste materials and sludges Part 2 One stage batch test at a liquid to solid ratio of.pdf EN 12457-2-2002 en Characterisation of waste Leaching Compliance test for leaching of granular waste materials and sludges Part 2 One stage batch test at a liquid to solid ratio of.pdf
  • EN 12457-3-2002 en Characterisation of waste Leaching Compliance test for leaching of granular waste materials and sludges Part 3 Two stage batch test at a liquid to solid ratio of.pdf EN 12457-3-2002 en Characterisation of waste Leaching Compliance test for leaching of granular waste materials and sludges Part 3 Two stage batch test at a liquid to solid ratio of.pdf
  • EN 12457-4-2002 en Characterisation of waste Leaching Compliance test for leaching of granular waste materials and sludges Part 4 One stage batch test at a liquid to solid ratio of.pdf EN 12457-4-2002 en Characterisation of waste Leaching Compliance test for leaching of granular waste materials and sludges Part 4 One stage batch test at a liquid to solid ratio of.pdf
  • EN 12458-1999 en Surface Active Agents - Determination of Stability in Hard Water《表面活性剂 硬水中稳定性的测定》.pdf EN 12458-1999 en Surface Active Agents - Determination of Stability in Hard Water《表面活性剂 硬水中稳定性的测定》.pdf
  • EN 1246-1998 en Adhesives - Determination of Ash and Sulphated Ash《胶粘剂 灰分含量和硫酸盐灰分含量的测定》.pdf EN 1246-1998 en Adhesives - Determination of Ash and Sulphated Ash《胶粘剂 灰分含量和硫酸盐灰分含量的测定》.pdf
  • EN 12460-1998 en Biotechnology - Large-Scale Process and Production - Guidance on Equipment Selection and Installation in Accordance with the Biological Risk《生物技术 大比例工艺法和生产 与生物危险性相.pdf EN 12460-1998 en Biotechnology - Large-Scale Process and Production - Guidance on Equipment Selection and Installation in Accordance with the Biological Risk《生物技术 大比例工艺法和生产 与生物危险性相.pdf
  • 相关搜索

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

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