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

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

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

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

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

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

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

6、signed char xx5080;int maxline=0;/*文章的总行数*/int ReadDat(void);void WriteDat(void);void eneryptChar()void main()system(“CLS“);if(ReadDat()printf(“数据文件 ENG4.IN不能打开!/n/007“);return;encryptChar();WriteDat();int ReadDat(void)FILE *fp;int i=0;unsigned char *p;if(fp=fopen(“ENG4.IN“,“r“)=NULL)return 1;while(

7、fgets(xxi,80,fp)!=NULL)P=strchr(xxi,/n);if(P) *P=0;i+;maxline=i;fclose(tp);return 0;void WriteDat(void)FILE *fp;int i;fp=tbpen(“PS4.DAT“,“w“);for(i=0;imaxline;i+)printf(“%s/n“,xxi);fprinff(fp,“%s/n“,xxi);fclose(fp);(分数:100.00)_正确答案:(void encryptChar()int i,j; /*定义循环控制变量*/int str; /*存储字符串的长度*/char ch

8、 /*存储当前取得的字符*/for(i=0;imaxline;i+) /*以行为单位获取字符*/str=strlen(xxi); /*求得当前行的字符串长度*/for(j=0;jstr;j+) /*依次取每行的各个字符*/ch=xxij *11%256;if(ch=32|ch130)continue; /*如果计算后的值小于等于 32或大于 130,则该字符不变*/elsexxij=ch; /*否则将所对应的字符进行替代*/)解析:解析 本题要对二维数组中的字符元素按行进行处理。首先用 stden()函数得到当前行所包含的字符总个数,然后再利用 for循环来依次访问该行中的所有字符。对于每一个字符,先按照题目中的函数替代关系“f(p)=p * 11 mod 256”计算出相应的 fp的值,再用一条 if语句判断该值是否符合本题给定的条件:计算后 f(p)的值小于等于 32或大于 130。如果符合条件,则该字符不变,否则用 f(p)所对应的字符对其进行替代。

展开阅读全文
相关资源
猜你喜欢
  • BS 5842-1980 Specification for thermoplastic hose assemblies for dock road and tanker use《船坞、道路及油轮用热塑性软管组件规范》.pdf BS 5842-1980 Specification for thermoplastic hose assemblies for dock road and tanker use《船坞、道路及油轮用热塑性软管组件规范》.pdf
  • BS 5849-1980 Method of expression of performance of air quality infra-red analysers《空气质量红外线分析仪性能表示方法》.pdf BS 5849-1980 Method of expression of performance of air quality infra-red analysers《空气质量红外线分析仪性能表示方法》.pdf
  • BS 585-1-1989 Wood stairs - Specification for stairs with closed risers for domestic use including straight and winder flights and quarter or half landings《木楼梯 第1部分 家用带封闭式梯级竖板的楼梯 包.pdf BS 585-1-1989 Wood stairs - Specification for stairs with closed risers for domestic use including straight and winder flights and quarter or half landings《木楼梯 第1部分 家用带封闭式梯级竖板的楼梯 包.pdf
  • BS 585-2-1985 Wood stairs - Specification for performance requirements for domestic stairs constructed of wood-based materials《木楼梯 第2部分 家用木基材料楼梯的性能要求规范》.pdf BS 585-2-1985 Wood stairs - Specification for performance requirements for domestic stairs constructed of wood-based materials《木楼梯 第2部分 家用木基材料楼梯的性能要求规范》.pdf
  • BS 5852-1-1979 Fire tests for furniture Part 1 Methods of test for the ignitability by smokers materials of upholstered composites for seating《家具的防火试验 第1部分 座椅软垫合成物燃烧材料可燃性的试验方法》.pdf BS 5852-1-1979 Fire tests for furniture Part 1 Methods of test for the ignitability by smokers materials of upholstered composites for seating《家具的防火试验 第1部分 座椅软垫合成物燃烧材料可燃性的试验方法》.pdf
  • BS 5852-2-1982 British Standard Fire tests for furniture Part 2 Methods of test for the ignitability of upholstered composites for seating by flaming sources《英国标准的家具用防火试验 第2部分 用燃烧源.pdf BS 5852-2-1982 British Standard Fire tests for furniture Part 2 Methods of test for the ignitability of upholstered composites for seating by flaming sources《英国标准的家具用防火试验 第2部分 用燃烧源.pdf
  • BS 5852-2006 Methods of test for assessment of the ignitability of upholstered seating by smouldering and flaming ignition sources《用闷燃和燃烧点火源对软座进行易燃性评价的试验方法》.pdf BS 5852-2006 Methods of test for assessment of the ignitability of upholstered seating by smouldering and flaming ignition sources《用闷燃和燃烧点火源对软座进行易燃性评价的试验方法》.pdf
  • BS 5853-1980 Specification for medicine trolleys《医用小推车规范》.pdf BS 5853-1980 Specification for medicine trolleys《医用小推车规范》.pdf
  • BS 5854-1980 Code of practice for flues and flue structures in buildings《建筑物中烟道和烟道结构实用规程》.pdf BS 5854-1980 Code of practice for flues and flue structures in buildings《建筑物中烟道和烟道结构实用规程》.pdf
  • 相关搜索

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

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