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

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

1、计算机三级数据库技术-132 及答案解析(总分: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 码值),如果计算后

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

3、 (void) ; void encryptChar () void main () system (“CLS“) ; if (ReadDat () 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 =

4、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“) ; for(i=0; imaxline; i+) printf(“%sn“, xxi); fprintf(fp, “%sn“, xxi); fclose (fp) ; (分数:100.00)_计算机三级数据库技术-132 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.0

5、0)1.函数 ReadDat()的功能是从文件 ENG.IN 中读取一篇英文文章,存入到字符串数组 xx 中。请编写函数encryptChar(),按给定的替代关系对数组 xx 中的所有字符进行替换,结果仍存入数组 xx 的对应的位置上,最后调用函数 WriteDat(),把结果 xx 输出到文件 PS.DAT 中。 替代关系:f(p)=p*11 mod 256(p 是数组 xx 中某一个字符的 ASCII 码值,f(p)是计算后新字符的 ASCII 码值),如果计算后 f(p)的值小于等于 32 或 f(p)对应的字符是数字 09,则该字符不变,否则将 f(p)所对应的字符进行替换。 注意:

6、原始数据文件存放的格式是:每行的宽度均小于 80 个字符。请勿改动主函数 main()、读函数ReadDat()和写函数 WriteDat()的内容。 【试题程序】 #include stdio.h #include string.h #include stdlib.h #include ctype.h unsigned char xx 50 80 ; int maxline = 0 ; /文章的总行数 int ReadDat (void) ; void WriteDat (void) ; void encryptChar () void main () system (“CLS“) ; if

7、 (ReadDat () 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; i+; maxline = i; fclose (fp)

8、 ; 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)_正确答案:()解析:void encryptChar() int i,j; /*定义循环控制变量*/ int str; /*存储字符串的长度*/ char ch; /*存储当前取得的字符*/ for(i=0;imaxline;i+) /*以行为单

9、位获取字符*/ str=strlen(xxi); /*求得当前行的字符串长度*/ for(j=0;jstr;j+) /*依次取每行的所有字符*/ ch=xxij*11%256; if(ch=32 | (ch=“0“ /*如果计算后的值小于等于 32 或 f(p)对应的字符是数字 0 至 9,则该字符不变*/ else xxij=ch; /*否则按给定的替代关系进行替代*/ 考点 本题考查对字符数组中字符计算和替换。考查的知识点主要包括:字符串数组的访问,字符ASCII 码的算术运算,if 判断结构以及逻辑表达式。 解析 此题属于字符替代问题;分析题干要求,可以归纳出 3 个关键点:关键点 1 如何对字符数组的元素逐个访问;关键点 2 如何根据给出的函数替代关系“f(p)p*11 mod 256“对字符进行计算;关键点 3 根据条件(本题为“计算后 f(p)的值小于等于 32 或 f(p)对应的字符是数字 0 至 9“)对计算结果进行判断,并分别对满足与不满足条件的情况进行处理。 本题与上题解题思路相同,不同的是替代关系的条件不同,本题为计算的 f(p)值不满足小于等于 32 或对应字符是数字 0 至 9。 根据函数替代关系对字符进行运算,if 判断结构中逻辑表达式。

展开阅读全文
相关资源
猜你喜欢
  • ETSI EN 302 842-4-2015 VHF air-ground and air-air Digital Link (VDL) Mode 4 radio equipment Technical characteristics and methods of measurement for aeronautical mobile (airborne) .pdf ETSI EN 302 842-4-2015 VHF air-ground and air-air Digital Link (VDL) Mode 4 radio equipment Technical characteristics and methods of measurement for aeronautical mobile (airborne) .pdf
  • ETSI EN 302 842-4-2015 VHF air-ground and air-air Digital Link (VDL) Mode 4 radio equipment Technical characteristics and methods of measurement for aeronautical mobile (airborne) _1.pdf ETSI EN 302 842-4-2015 VHF air-ground and air-air Digital Link (VDL) Mode 4 radio equipment Technical characteristics and methods of measurement for aeronautical mobile (airborne) _1.pdf
  • ETSI EN 302 858-1-2013 Electromagnetic compatibility and Radio spectrum Matters (ERM) Road Transport and Traffic Telematics (RTTT) Automotive radar equipment operating in the 24 05.pdf ETSI EN 302 858-1-2013 Electromagnetic compatibility and Radio spectrum Matters (ERM) Road Transport and Traffic Telematics (RTTT) Automotive radar equipment operating in the 24 05.pdf
  • ETSI EN 302 858-2-2013 Electromagnetic compatibility and Radio spectrum Matters (ERM) Road Transport and Traffic Telematics (RTTT) Automotive radar equipment operating in the 24 05.pdf ETSI EN 302 858-2-2013 Electromagnetic compatibility and Radio spectrum Matters (ERM) Road Transport and Traffic Telematics (RTTT) Automotive radar equipment operating in the 24 05.pdf
  • ETSI EN 302 858-2016 Short Range Devices Transport and Traffic Telematics (TTT) Radar equipment operating in the 24 05 GHz to 24 25 GHz or 24 05 GHz to 24 50 GHz range Harmonised S.pdf ETSI EN 302 858-2016 Short Range Devices Transport and Traffic Telematics (TTT) Radar equipment operating in the 24 05 GHz to 24 25 GHz or 24 05 GHz to 24 50 GHz range Harmonised S.pdf
  • ETSI EN 302 858-2016 Short Range Devices Transport and Traffic Telematics (TTT) Radar equipment operating in the 24 05 GHz to 24 25 GHz or 24 05 GHz to 24 50 GHz range Harmonised S_1.pdf ETSI EN 302 858-2016 Short Range Devices Transport and Traffic Telematics (TTT) Radar equipment operating in the 24 05 GHz to 24 25 GHz or 24 05 GHz to 24 50 GHz range Harmonised S_1.pdf
  • ETSI EN 302 878-1-2011 Access Terminals Transmission and Multiplexing (ATTM) Third Generation Transmission Systems for Interactive Cable Television Services - IP Cable Modems Part .pdf ETSI EN 302 878-1-2011 Access Terminals Transmission and Multiplexing (ATTM) Third Generation Transmission Systems for Interactive Cable Television Services - IP Cable Modems Part .pdf
  • ETSI EN 302 878-1-2011 Access Terminals Transmission and Multiplexing (ATTM) Third Generation Transmission Systems for Interactive Cable Television Services - IP Cable Modems Part _1.pdf ETSI EN 302 878-1-2011 Access Terminals Transmission and Multiplexing (ATTM) Third Generation Transmission Systems for Interactive Cable Television Services - IP Cable Modems Part _1.pdf
  • ETSI EN 302 878-2-2011 Access Terminals Transmission and Multiplexing (ATTM) Third Generation Transmission Systems for Interactive Cable Television Services - IP Cable Modems Part .pdf ETSI EN 302 878-2-2011 Access Terminals Transmission and Multiplexing (ATTM) Third Generation Transmission Systems for Interactive Cable Television Services - IP Cable Modems Part .pdf
  • 相关搜索

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

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