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

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

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

2、值是偶数或计算后 f(p)的值小于等于 32,则该字符不变,否则,将 f(p)所对应的字符进行替换。 注意:原始数据文件存放的格式是:每行的宽度均小于 80个字符。请勿改动主函数 main()、读函数ReadDat()和写函数 WriteDat()的内容。 【试题程序】 #include stdio.h #include string.h #include stdlib.h #include ctype.h unsigned char xx5080; int maxline =0; /文章的总行数 int ReadDat(void); void WriteDat(void); void enc

3、ryptChar() void main() system(“CLS“); if (Readmat () printf (“数据文件 ENG. IN 无法打开! n007“); 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

4、 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(“%sn“, xxi); fprintf(fp, “%sn“, xxi); fclose(fp); (分数:100.00)_计算机三级数据库技术-131 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是从文件 ENG.IN中读取一篇英文文章,

5、存入字符串数组 xx中。请编写函数encryptChar(),按给定的替代关系对数组 xx中的所有字符进行替换,替换后的字符仍存入数组 xx的对应的位置上,最后调用函数 WriteDat(),把结果 xx输出到文件 PS.DAT中。 替代关系:f(p)=p*11 mod 256(p 是数组 xx中某一个字符的 ASCII码值,f(p)是计算后新字符的 ASCII码值),如果原字符的 ASCII值是偶数或计算后 f(p)的值小于等于 32,则该字符不变,否则,将 f(p)所对应的字符进行替换。 注意:原始数据文件存放的格式是:每行的宽度均小于 80个字符。请勿改动主函数 main()、读函数Re

6、adDat()和写函数 WriteDat()的内容。 【试题程序】 #include stdio.h #include string.h #include stdlib.h #include ctype.h unsigned char xx5080; int maxline =0; /文章的总行数 int ReadDat(void); void WriteDat(void); void encryptChar() void main() system(“CLS“); if (Readmat () printf (“数据文件 ENG. IN 无法打开! n007“); return; encry

7、ptChar(); 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; int i; fp = fopen (“PS.DAT“, “w

8、) ; for(i=0; imaxline; i+) printf(“%sn“, xxi); fprintf(fp, “%sn“, xxi); fclose(fp); (分数:100.00)_正确答案:()解析:void encryptChar() int i,j; /*定义循环控制变量*/ int str; /*存储字符串的长度*/ char ch; /*存储当前取得的字符*/ for(i=0;imaxline;i+) /*以行为单位获取字符*/ str=strlen(xxi); /*求得当前行的字符串长度*/ for(j=0;jstr;j+) /*依次取每行的所有字符*/ ch=xxij

9、11%256; if(xxij%2=0 | ch=32) continue; /*如果原字符的 ASCII值是偶数或计算后的值小于等于 32,则该字符不变*/ else xxij=ch; /*否则将所对应的字符进行替代*/ 考点 本题考查对字符数组中字符计算和替换。考查的知识点主要包括:字符串数组的访问,字符ASCII码的算术运算,if 判断结构以及逻辑表达式。 解析 此题属于字符替代问题;分析题干要求,可以归纳出 3个关键点:关键点 1如何对字符数组的元素逐个访问;关键点 2如何根据给出的函数替代关系“f(p)p*11 mod 256“对字符进行计算;关键点 3根据条件(本题为“原字符的 ASCII值是偶数或计算后 f(p)的值小于等于 32“)对计算结果进行判断,并分别对满足与不满足条件的情况进行处理。 通过问题分析,得出解此题的思路为:首先通过字符串处理函数 strlen获取字符串的长度,根据获得的长度使用下标法逐一对字符数组的元素进行访问;然后按照题目给出的函数关系式直接对字符进行算术运算;最后通过 if判断结构和逻辑表达式判断计算结果是否满足条件,分别对两种情况进行处理。 根据函数替代关系对字符进行运算,if 判断结构中逻辑表达式。

展开阅读全文
相关资源
猜你喜欢
  • GOST 23592-1996 Electrical wiring of radio-electronic equipment and devices General requirements for three-dimensional wiring of electronic and electrical devices《无线电电子设备与仪表的电器安装 电.pdf GOST 23592-1996 Electrical wiring of radio-electronic equipment and devices General requirements for three-dimensional wiring of electronic and electrical devices《无线电电子设备与仪表的电器安装 电.pdf
  • GOST 23593-1979 Mounting of electric radioelectronic equipment and instruments using flexible matrices Technical requirements《无线电电子装置及采用柔性模型的仪器的电气安装 技术要求》.pdf GOST 23593-1979 Mounting of electric radioelectronic equipment and instruments using flexible matrices Technical requirements《无线电电子装置及采用柔性模型的仪器的电气安装 技术要求》.pdf
  • GOST 23594-1979 Mounting of electric radioelectronic equipment and instruments Marking《无线电电子装置和仪器的电气装置 标志》.pdf GOST 23594-1979 Mounting of electric radioelectronic equipment and instruments Marking《无线电电子装置和仪器的电气装置 标志》.pdf
  • GOST 23595-1979 Control signals line and acoustic signals of the single frequency signalling system for the trunk and intrazone telephone network Electrical parameters and measurin.pdf GOST 23595-1979 Control signals line and acoustic signals of the single frequency signalling system for the trunk and intrazone telephone network Electrical parameters and measurin.pdf
  • GOST 23597-1979 Machine tools numerically controlled Designation of axis and motion directions General statements《数字程序控制金属切削机床 座标轴标志及运动方向 一般规则》.pdf GOST 23597-1979 Machine tools numerically controlled Designation of axis and motion directions General statements《数字程序控制金属切削机床 座标轴标志及运动方向 一般规则》.pdf
  • GOST 23598-1979 Pin cable lugs Construction and dimensions《接线柱式电缆头 结构与尺寸》.pdf GOST 23598-1979 Pin cable lugs Construction and dimensions《接线柱式电缆头 结构与尺寸》.pdf
  • GOST 23599-1979 Enamels type EP-255 and EP-275 Specifications《瓷漆ЭП-255和ЭП-275 技术条件》.pdf GOST 23599-1979 Enamels type EP-255 and EP-275 Specifications《瓷漆ЭП-255和ЭП-275 技术条件》.pdf
  • GOST 23600-1979 Food concentrates Dry soups with fish and sea products Specifications《浓缩食品 浓缩鱼和水产干汤料 技术条件》.pdf GOST 23600-1979 Food concentrates Dry soups with fish and sea products Specifications《浓缩食品 浓缩鱼和水产干汤料 技术条件》.pdf
  • GOST 23611-1979 Electromagnetic compatibility of radio-electronic equipment Terms and definitions《无线电电子设备的电磁兼容性 术语和定义》.pdf GOST 23611-1979 Electromagnetic compatibility of radio-electronic equipment Terms and definitions《无线电电子设备的电磁兼容性 术语和定义》.pdf
  • 相关搜索

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

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