【计算机类职业资格】三级数据库技术机试-71及答案解析.doc

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

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

2、 fb)值小于等于 32,则该字符不变,否则将 qp)所对应的字符进行替代。部分源程序己给出,原始数据文件存放的格式是:每行的宽度均小于 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 main()c

3、lrscr();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)FILE *fp;i

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

5、Dat()把结果 xx 输出到文件 ps10dat 中。替代关系:f(p)=p*43 mod 256(p 是数组中某一个字符的 ASCII 值,fO)是计算后新字符的 ASCII 值),如果原字符的 ASCII 值是偶数或计算后 fb)值小于等于 32,则该字符不变,否则将 qp)所对应的字符进行替代。部分源程序己给出,原始数据文件存放的格式是:每行的宽度均小于 80 个字符。请勿改动主函数 main()、读数据函数 ReadDat()和输出数据函数 WriteDat()的内容。#includestdio.h#includestring.h#includeconio.h#includectyp

6、e.hunsigned char xx5080;int maxline=0;/*文章的总行数*/int ReadDat(void)void WriteDat(void)void encryptChar()void main()clrscr();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

7、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(“ps10.dat“,“w“);for(i=0;imaxline;i+)printf(“%s/n“,xxi);fprintf(fp,“%s/n“,xxi);fclose(fp);(分数:100.00)_正确答案:(提示:类型:字符替换。关键点:1字符串读写。2由于 fgets()函数读入数据时读入换行符/n,因而需要在 xx 数组每一行末尾将

8、换行符/n替换成结束符/0。本题中此步已经在 ReadDat()函数中完成。3算法:让字符指针 pf 指向每一行的开头然后逐一往后移动,在移动过程中按要求进行转换。*pf%20 用于判断是否为偶数。If()条件语句用于控制不替代字符。4中间变量的类型选择整型。解答:void encryptChar()/*字符替换过程中,运算的中间结果可能超过 256*/*因此采用整型存储中间结果*/int i,j,t;for(i=0;imaxline;i+)/*遍历每一行*/for(j=0;istrlen(xxi);j+)/*用控型变量进行所有运算*/t=xxij;t=t*43%256;/*判断替换条件*/if(t=32 | xxij%2=0) continue;xxij=t;)解析:

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 3843-1999 Aerospace Series Nuts Bihexagonal Self-Locking with Counterbore in Heat Resisting Steel Passivated Classification 1 100 MPa (at Ambient Temperature) 650 Degree.pdf AECMA PREN 3843-1999 Aerospace Series Nuts Bihexagonal Self-Locking with Counterbore in Heat Resisting Steel Passivated Classification 1 100 MPa (at Ambient Temperature) 650 Degree.pdf
  • AECMA PREN 3844-1-1995 Aerospace Series Flammability of Non Metallic Materials Part 1  Small Burner Test Vertical Determination of the Vertical Flame Propagation Edition P 1《航空航天系列.pdf AECMA PREN 3844-1-1995 Aerospace Series Flammability of Non Metallic Materials Part 1 Small Burner Test Vertical Determination of the Vertical Flame Propagation Edition P 1《航空航天系列.pdf
  • AECMA PREN 3844-2-1995 Aerospace Series Flammability of Non Metallic Materials Part 2  Small Burner Test Horizontal Determination of the Horizontal Flame Propagation Edition P 1《航空.pdf AECMA PREN 3844-2-1995 Aerospace Series Flammability of Non Metallic Materials Part 2 Small Burner Test Horizontal Determination of the Horizontal Flame Propagation Edition P 1《航空.pdf
  • AECMA PREN 3844-3-1995 Aerospace Series Flammability of Nom Metallic Materials Part 3  Small Burner Test 45 Degrees Determination of the Resistance of Material to Flame and Glow Pr.pdf AECMA PREN 3844-3-1995 Aerospace Series Flammability of Nom Metallic Materials Part 3 Small Burner Test 45 Degrees Determination of the Resistance of Material to Flame and Glow Pr.pdf
  • AECMA PREN 3845-2009 Aerospace series Rings retaining radial mounting in corrosion resisting steel passivated Edition P 1《航空航天系列.钝化耐腐蚀钢径向安装固定环.版本P1》.pdf AECMA PREN 3845-2009 Aerospace series Rings retaining radial mounting in corrosion resisting steel passivated Edition P 1《航空航天系列.钝化耐腐蚀钢径向安装固定环.版本P1》.pdf
  • AECMA PREN 3847-1997 Aerospace Series Paints and Varnishes Determination of the Sedimentation Rating Edition P 2《航空航天系列.色漆和清漆 沉淀值的测定》.pdf AECMA PREN 3847-1997 Aerospace Series Paints and Varnishes Determination of the Sedimentation Rating Edition P 2《航空航天系列.色漆和清漆 沉淀值的测定》.pdf
  • AECMA PREN 3848-1996 Aerospace Series Semi-Finished Metallic Products Methods of Measuring from Deviations Edition P2《航空航天系列半成品金属产品背离测量》.pdf AECMA PREN 3848-1996 Aerospace Series Semi-Finished Metallic Products Methods of Measuring from Deviations Edition P2《航空航天系列半成品金属产品背离测量》.pdf
  • AECMA PREN 3851-1995 Aerospace Series Pipe Couplings 60 Degrees Spherical in Titanium Alloy TI-P64001 Swivel Nuts Straight Edition P1《航空航天系列导管接头 60度球形钛合金TI-P64001直旋转轴》.pdf AECMA PREN 3851-1995 Aerospace Series Pipe Couplings 60 Degrees Spherical in Titanium Alloy TI-P64001 Swivel Nuts Straight Edition P1《航空航天系列导管接头 60度球形钛合金TI-P64001直旋转轴》.pdf
  • AECMA PREN 3852-1995 Aerospace Series Pipe Couplings 60 Degrees Spherical in Titanium Alloy TI-P64001 Straight Unions Welded Threaded Edition P1《航空航天系列导管接头 60度球形钛合金TI-P64001 直活管节线性.pdf AECMA PREN 3852-1995 Aerospace Series Pipe Couplings 60 Degrees Spherical in Titanium Alloy TI-P64001 Straight Unions Welded Threaded Edition P1《航空航天系列导管接头 60度球形钛合金TI-P64001 直活管节线性.pdf
  • 相关搜索

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

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