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

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

1、三级网络技术机试-220 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()实现从文件 IN.DAT中读取一篇英文文章,存到字符串数组 XX中;请编制函数encryptChar(),按给定的替代关系对数组 XX中的所有字符进行替代,仍存入数组 XX对应的位置上,最后调用函数 WriteDat()把结果 XX输出到文件 OUT.DAT中。替代关系:f(p)=P*13mod 256,mod 为取余运算,P 是数组 XX中某一个字符的 ASC值,f(p)是计算后的无符号整型值(注意:中间变量定义成整型变量),如果计算后 f(

2、p)值小于等于 32或是偶数,则该字符不变,否则用 f(p)替代所对应的字符。注意:部分源程序存放在 PROG1.C中,原始数据文件存放的格式是:每行的宽度均小于 80个字符,含标点符号和空格,并也按此替代关系进行处理。请勿改动主函数 main()、读函数 ReadDat()和输出函数WriteDat()的内容。试题程序#include #include #include unsigned char XX5080;int maxline=0;/*文章的总行数*/int ReadDat(void);void WriteDat(void);void encryptChar();void main(

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

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

5、OUT.DAT中。替代关系:f(p)=P*13mod 256,mod 为取余运算,P 是数组 XX中某一个字符的 ASC值,f(p)是计算后的无符号整型值(注意:中间变量定义成整型变量),如果计算后 f(p)值小于等于 32或是偶数,则该字符不变,否则用 f(p)替代所对应的字符。注意:部分源程序存放在 PROG1.C中,原始数据文件存放的格式是:每行的宽度均小于 80个字符,含标点符号和空格,并也按此替代关系进行处理。请勿改动主函数 main()、读函数 ReadDat()和输出函数WriteDat()的内容。试题程序#include #include #include unsigned c

6、har XX5080;int maxline=0;/*文章的总行数*/int ReadDat(void);void WriteDat(void);void encryptChar();void main()if (ReadDat()printf(“数据文件 INDAT不能打开!/n/007“);return;encryptChar();WriteDat();int ReadDat(void)FILE *fp;int i=0;unsigned char *p;if(fp=fopen(“in.dat“,“r“)=NULL)return 1;while(fgets(xxi,80,fp)!=NULL)

7、p=strchr(xxi,/n);if (p) *P=0;i+;maxline=i;fclose(fp);return 0;void WriteDat(void)FILE *fp;int i;fp=fopen(“out.dat“,“w“);for(i=0;imaxline;i+)printf(“%s/n“,xxi);fprintf(fp,“%s/n“,xxi);fclose(fp);(分数:100.00)_正确答案:(void encryptChar()int i,j,val; /*定义变量*/for(i=0;imaxline;i+) /*替代字符*/for(j=0;j80;j+)val=XXij*13%256; /*替代关系*/if(vab32|val%2=0)/*判断条件*/continue;else XXij=val;)解析:解析 本题要求逐行逐字将一篇英文文童进行处理,将其中的部分字符按照一定的判断条件进行替代。依据题意,应按照题目中给出的(p*13 mod 256)表达式依次计算每个字符对应的值 f(p),符合判断条件(计算后 f(p)值小于等于 32或为偶数,即 val32|val%2=0)的字符不变,其他字符替换为 f(p)。注意,为保证计算结果不溢出,中间变量必须定义为整型变量或无符号字符型变量。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 3614-1990 Aerospace Series Bolts Normal Hexagon Head Relieved Shank Long Thread in Heat Resisting Steel FE-PA92HT (A286) Silver Plated Classification  900 MPa 650 Degree.pdf AECMA PREN 3614-1990 Aerospace Series Bolts Normal Hexagon Head Relieved Shank Long Thread in Heat Resisting Steel FE-PA92HT (A286) Silver Plated Classification 900 MPa 650 Degree.pdf
  • AECMA PREN 3615-1998 Aerospace Series Fibre Reinforced Plastics Determination of the Conditions of Exposure to Humid Atmosphere and of Moisture Absorption Edition P 2《航空航天系列.纤维增强塑料.pdf AECMA PREN 3615-1998 Aerospace Series Fibre Reinforced Plastics Determination of the Conditions of Exposure to Humid Atmosphere and of Moisture Absorption Edition P 2《航空航天系列.纤维增强塑料.pdf
  • AECMA PREN 3616-1991 Aerospace Series Fibre Reinforced Plastics Test Method for the Determination of Moisture Content by Means of Moisture Evolution Analyser (MEA) Issue P 1《航空航天系列.pdf AECMA PREN 3616-1991 Aerospace Series Fibre Reinforced Plastics Test Method for the Determination of Moisture Content by Means of Moisture Evolution Analyser (MEA) Issue P 1《航空航天系列.pdf
  • AECMA PREN 3618-2009 Aerospace series Rivets solid 100 degrees countersunk normal head in titanium alloy Ti 44 5 Cb inch based series Edition P 1《航空航天系列.钛合金Ti44 5 Cb、100°标称埋头实心铆钉 英.pdf AECMA PREN 3618-2009 Aerospace series Rivets solid 100 degrees countersunk normal head in titanium alloy Ti 44 5 Cb inch based series Edition P 1《航空航天系列.钛合金Ti44 5 Cb、100°标称埋头实心铆钉 英.pdf
  • AECMA PREN 3624-1996 Aerospace Series Polysulphide Sealants Two-Component Technical Specification Edition P 1《航空航天系列.多硫化物两成分密封剂技术规范.P1版》.pdf AECMA PREN 3624-1996 Aerospace Series Polysulphide Sealants Two-Component Technical Specification Edition P 1《航空航天系列.多硫化物两成分密封剂技术规范.P1版》.pdf
  • AECMA PREN 3626-1996 Aerospace Series Nuts Hexagon Self-Locking in Steel Cadmium Plated MoS2 Lubricated Classification 1 100 MPa (at Ambient Temperature) 235 Degrees C Edition P 2《.pdf AECMA PREN 3626-1996 Aerospace Series Nuts Hexagon Self-Locking in Steel Cadmium Plated MoS2 Lubricated Classification 1 100 MPa (at Ambient Temperature) 235 Degrees C Edition P 2《.pdf
  • AECMA PREN 3628-1991 Aerospace Series Lockwire Drawn Corrosion Resisting Steel Issue P 1《航空航天系列.卷边冷拉防腐蚀钢.P1版》.pdf AECMA PREN 3628-1991 Aerospace Series Lockwire Drawn Corrosion Resisting Steel Issue P 1《航空航天系列.卷边冷拉防腐蚀钢.P1版》.pdf
  • AECMA PREN 3629-1989 Aerospace Series Ball Bearings Rigid in Corrosion Resisting Steel for Control Cable Pulleys Dimensions and Loads Issue P 1《航空航天系列.滚珠轴承防腐蚀钢用于控制电缆所论尺寸和重量.P1版》.pdf AECMA PREN 3629-1989 Aerospace Series Ball Bearings Rigid in Corrosion Resisting Steel for Control Cable Pulleys Dimensions and Loads Issue P 1《航空航天系列.滚珠轴承防腐蚀钢用于控制电缆所论尺寸和重量.P1版》.pdf
  • AECMA PREN 3630-1992 Aerospace Series Fluid Fittings Flanged Straight Sealing by O-Ring for 0 8 mm Thick Tubes Edition P 1《航空航天系列.流动装配法兰O形直密封厚度关0 8 mm.P1版》.pdf AECMA PREN 3630-1992 Aerospace Series Fluid Fittings Flanged Straight Sealing by O-Ring for 0 8 mm Thick Tubes Edition P 1《航空航天系列.流动装配法兰O形直密封厚度关0 8 mm.P1版》.pdf
  • 相关搜索

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

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