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

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

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

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

3、rscr();if (ReadDat ()printf (“数据文件 ENG49. IN 不能打开!/n/007“);return;encryChar();WriteDat();int ReadDat (void)FILE *fp;int i=0;unsigned char *p;if(fp=fopen(“ENG49.IN“,“r“)=NULL)return 1;while(fgets(xxi,80,fp) !=NULL)p=strchr(xxi,/n);if(p) *p=07i+;maxline=i;fclose(fp);return 0;void WriteDat()FILE *fp;in

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

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

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

7、while(fgets(xxi,80,fp) !=NULL)p=strchr(xxi,/n);if(p) *p=07i+;maxline=i;fclose(fp);return 0;void WriteDat()FILE *fp;int i;fp=fopen(“ps49.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

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

展开阅读全文
相关资源
猜你喜欢
  • BS ISO IEC 29341-30-11-2017 Information technology UPnP Device Architecture IoT management and control device control protocol IoT management and control data model service《信息技术 UP.pdf BS ISO IEC 29341-30-11-2017 Information technology UPnP Device Architecture IoT management and control device control protocol IoT management and control data model service《信息技术 UP.pdf
  • BS ISO IEC 29341-30-12-2017 Information technology UPnP Device Architecture IoT management and control device control protocol IoT management and control transport generic service《.pdf BS ISO IEC 29341-30-12-2017 Information technology UPnP Device Architecture IoT management and control device control protocol IoT management and control transport generic service《.pdf
  • BS ISO IEC 29341-30-2-2017 Information technology UPnP Device Architecture IoT management and control device control protocol IoT management and control device《信息技术 UPnP设备体系结构 物联网管.pdf BS ISO IEC 29341-30-2-2017 Information technology UPnP Device Architecture IoT management and control device control protocol IoT management and control device《信息技术 UPnP设备体系结构 物联网管.pdf
  • BS ISO IEC 29341-31-1-2017 Information technology UPnP Device Architecture Energy management device control protocol Energy management service《信息技术 UPnP设备体系结构 能量管理设备控制协议 能源管理处》.pdf BS ISO IEC 29341-31-1-2017 Information technology UPnP Device Architecture Energy management device control protocol Energy management service《信息技术 UPnP设备体系结构 能量管理设备控制协议 能源管理处》.pdf
  • BS ISO IEC 29500-3-2015 Information technology Document description and processing languages Office Open XML File Formats Markup Compatibility and Extensibility《信息技术 文献描述和处理语言 办公开放.pdf BS ISO IEC 29500-3-2015 Information technology Document description and processing languages Office Open XML File Formats Markup Compatibility and Extensibility《信息技术 文献描述和处理语言 办公开放.pdf
  • BS ISO IEC 30105-1-2016 Information technology IT Enabled Services-Business Process Outsourcing (ITES-BPO) lifecycle processes Process reference model (PRM)《信息技术 科技化服务业务流程外包(ITES-B.pdf BS ISO IEC 30105-1-2016 Information technology IT Enabled Services-Business Process Outsourcing (ITES-BPO) lifecycle processes Process reference model (PRM)《信息技术 科技化服务业务流程外包(ITES-B.pdf
  • BS ISO IEC 30105-2-2016 Information technology IT Enabled Services-Business Process Outsourcing (ITES-BPO) lifecycle processes Process assessment model (PAM)《信息技术 科技化服务业务流程外包(ITES-.pdf BS ISO IEC 30105-2-2016 Information technology IT Enabled Services-Business Process Outsourcing (ITES-BPO) lifecycle processes Process assessment model (PAM)《信息技术 科技化服务业务流程外包(ITES-.pdf
  • BS ISO IEC 30105-3-2016 Information technology IT Enabled Services-Business Process Outsourcing (ITES-BPO) lifecycle processes Measurement framework (MF) and organization maturity .pdf BS ISO IEC 30105-3-2016 Information technology IT Enabled Services-Business Process Outsourcing (ITES-BPO) lifecycle processes Measurement framework (MF) and organization maturity .pdf
  • BS ISO IEC 30105-4-2016 Information technology IT Enabled Services-Business Process Outsourcing (ITES-BPO) lifecycle processes Terms and concepts《信息技术 科技化服务业务流程外包(ITES-BPO)生命周期过程 术.pdf BS ISO IEC 30105-4-2016 Information technology IT Enabled Services-Business Process Outsourcing (ITES-BPO) lifecycle processes Terms and concepts《信息技术 科技化服务业务流程外包(ITES-BPO)生命周期过程 术.pdf
  • 相关搜索

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

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