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

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

1、计算机三级数据库技术-134 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是从文件 IN.DAT 中读取一篇英文文章存入到字符串数组 xx 中。请编写函数CovertCharD(),该函数的功能是:以行为单位把字符串中的所有小写字母改成该字母的上一个字母,如果是字母 a,则改成字母 z。大写字母仍为大写字母,小写字母仍为小写字母,其他字符不变。把已处理的字符串仍按行重新存入字符串数组 xx 中,最后调用函数 WriteDat(),把结果 xx 输出到文件 OUT.DAT中。 例如, 原文 Adb Bcdza

2、 abck LLhj 结果 Aca Bbcyz zabj LLgi 原始数据文件存放的格式是:每行的宽度均小于 80 个字符(含标点符号和空格)。 注意:请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。 【试题程序】 #include stdio.h #include string.h #include stdlib.h char xx5080; int maxline = 0 ; int ReadDat (void) ; void WriteDat (void) ; void CovertCharD () void main () system

3、CLS“) ; if (Readmat () printf (“数据文件 IN.DAT 无法打开 n007“) ; return; CovertCharD () ; WriteDat () ; int ReadDat () FILE * fp; int i =0; 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)

4、 return 0 ; void WriteDat (void) FILE * fp; int i ; system (“CLS“) ; fp = fopen (“OUT. DAT“, “w“) ; for (i =0;i maxline;i + ) printf (“%sn“,xxi ) ; fprint f (fp, “%sn“, xxi ) ; fclose (fp) ; (分数:100.00)_计算机三级数据库技术-134 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是从文件 IN.DAT 中读取一

5、篇英文文章存入到字符串数组 xx 中。请编写函数CovertCharD(),该函数的功能是:以行为单位把字符串中的所有小写字母改成该字母的上一个字母,如果是字母 a,则改成字母 z。大写字母仍为大写字母,小写字母仍为小写字母,其他字符不变。把已处理的字符串仍按行重新存入字符串数组 xx 中,最后调用函数 WriteDat(),把结果 xx 输出到文件 OUT.DAT中。 例如, 原文 Adb Bcdza abck LLhj 结果 Aca Bbcyz zabj LLgi 原始数据文件存放的格式是:每行的宽度均小于 80 个字符(含标点符号和空格)。 注意:请勿改动主函数 main()、读函数 R

6、eadDat()和写函数 WriteDat()的内容。 【试题程序】 #include stdio.h #include string.h #include stdlib.h char xx5080; int maxline = 0 ; int ReadDat (void) ; void WriteDat (void) ; void CovertCharD () void main () system (“CLS“) ; if (Readmat () printf (“数据文件 IN.DAT 无法打开 n007“) ; return; CovertCharD () ; WriteDat ()

7、 int ReadDat () FILE * fp; int i =0; 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 ; system (“CLS“) ; fp = fopen (“OUT. DAT“, “w“

8、) ; for (i =0;i maxline;i + ) printf (“%sn“,xxi ) ; fprint f (fp, “%sn“, xxi ) ; fclose (fp) ; (分数:100.00)_正确答案:()解析:void CovertCharD() int i,j; /*定义循环控制变量*/ int str; /*存储字符串的长度*/ for(i=0;imaxline;i+) /*逐行获取字符串*/ str=strlen(xxi); /*求得各行的字符长度*/ for(j=0;jstr;j+) /*逐个取每个字符进行处理*/ if(xxij=“a“ /*如果是小写字母 a

9、就改成字母 z*/ else xxij-=1; /*其余的改成该字母的上一个字母*/ 考点 本题考查对字符串中字符的替换。考查的知识点主要包括:字符串数组的访问,字符之间的比较和替换,if 判断结构以及逻辑表达式。 解析 此题属于字符替换题型;分析题干要求,可以归纳出 2 个关键点:关键点 1 如何实现对字符数组的元素逐一访问;关键点 2 如何根据条件“把所有的小写字母改写成该字母的上一个字母“对字符进行替换。接着分析具体的解决方法,首先通过字符串处理函数 strlen 获取字符串的长度,根据获得的长度使用下标法对字符数组的元素逐一访问,判断每个字符是否是小写字符,如果是则将字符替换为其上一个字符,其中对于小写字母“a“,要将其替换成小写字母“z“,这些可以通过 if 判断结构和逻辑表达式来完成。 对字符数组进行逐元素访问;if 判断结构中逻辑表达式。

展开阅读全文
相关资源
猜你喜欢
  • SAE AMS 5922B-2015 Steel Corrosion-Resistant Bars and Forgings 10Cr - 5 5Ni - 14Co - 2Mo - 1W (0 19-0 23C) Vacuum Induction Melted Vacuum Arc Remelted Normalized Annealed (UNS S105.pdf SAE AMS 5922B-2015 Steel Corrosion-Resistant Bars and Forgings 10Cr - 5 5Ni - 14Co - 2Mo - 1W (0 19-0 23C) Vacuum Induction Melted Vacuum Arc Remelted Normalized Annealed (UNS S105.pdf
  • SAE AMS 5923-2013 Steel Corrosion-Resistant Bars Wire and Forgings 17Cr - 0 52Mo (0 95 - 1 20C) (440C) for Bearing Applications (UNS S44004)《轴承用耐腐蚀钢棒材、线材和锻材17Cr 0 52Mo (0 95 - 1 20.pdf SAE AMS 5923-2013 Steel Corrosion-Resistant Bars Wire and Forgings 17Cr - 0 52Mo (0 95 - 1 20C) (440C) for Bearing Applications (UNS S44004)《轴承用耐腐蚀钢棒材、线材和锻材17Cr 0 52Mo (0 95 - 1 20.pdf
  • SAE AMS 5925A-2006 Steel Corrosion-Resistant Bars Wire and Forgings 15 5Cr - 1 8Mo - 0 20N (0 37 - 0 45C) Electroslag Remelted (UNS S42025)《15 5Cr 1 8Mo 0 20N (0 37 - 0 45 C)电渣重熔的耐.pdf SAE AMS 5925A-2006 Steel Corrosion-Resistant Bars Wire and Forgings 15 5Cr - 1 8Mo - 0 20N (0 37 - 0 45C) Electroslag Remelted (UNS S42025)《15 5Cr 1 8Mo 0 20N (0 37 - 0 45 C)电渣重熔的耐.pdf
  • SAE AMS 5926-2010 Steel Corrosion-Resistant Bars Wire Tubing and Forgings 15 5Cr - 1 5Si - 0 3Mo - 0 1N (0 45 - 0 60C) for Bearing Applications (UNS S42716)《轴承应用件用1 5Cr 1 5Si 0 3Mo.pdf SAE AMS 5926-2010 Steel Corrosion-Resistant Bars Wire Tubing and Forgings 15 5Cr - 1 5Si - 0 3Mo - 0 1N (0 45 - 0 60C) for Bearing Applications (UNS S42716)《轴承应用件用1 5Cr 1 5Si 0 3Mo.pdf
  • SAE AMS 5928-2010 Steel Corrosion-Resistant Bars Wire and Forgings 12Cr - 9Ni - 2Mo - 0 7Al - 0 3Ti Vacuum Induction Plus Vacuum Consumable Electrode Melted Solution Heat Treated P.pdf SAE AMS 5928-2010 Steel Corrosion-Resistant Bars Wire and Forgings 12Cr - 9Ni - 2Mo - 0 7Al - 0 3Ti Vacuum Induction Plus Vacuum Consumable Electrode Melted Solution Heat Treated P.pdf
  • SAE AMS 5929-2008 Steel Corrosion-Resistant Bars and Forgings 11 5Cr -10Ni C 1 0Al C 0 5Ti C 1 0Cu C 1 0W Vacuum Induction Plus Vacuum Consumable Electrode Melted Solution Heat Tre.pdf SAE AMS 5929-2008 Steel Corrosion-Resistant Bars and Forgings 11 5Cr -10Ni C 1 0Al C 0 5Ti C 1 0Cu C 1 0W Vacuum Induction Plus Vacuum Consumable Electrode Melted Solution Heat Tre.pdf
  • SAE AMS 5930A-2005 Steel Corrosion-Resistant Bars and Forgings 13 0Cr - 2 5Ni - 5 5Co - 2 0Mo - 0 60V (0 05 - 0 09C) Vacuum Induction Plus Vacuum Consumable Electrode Melted《真空感应加真.pdf SAE AMS 5930A-2005 Steel Corrosion-Resistant Bars and Forgings 13 0Cr - 2 5Ni - 5 5Co - 2 0Mo - 0 60V (0 05 - 0 09C) Vacuum Induction Plus Vacuum Consumable Electrode Melted《真空感应加真.pdf
  • SAE AMS 5930B-2017 Steel Corrosion-Resistant Bars and Forgings 13 0Cr - 2 5Ni - 5 5Co - 2 0Mo - 0 60V (0 05 - 0 09C) Vacuum Induction Plus Vacuum Consumable Electrode Melted (UNS S.pdf SAE AMS 5930B-2017 Steel Corrosion-Resistant Bars and Forgings 13 0Cr - 2 5Ni - 5 5Co - 2 0Mo - 0 60V (0 05 - 0 09C) Vacuum Induction Plus Vacuum Consumable Electrode Melted (UNS S.pdf
  • SAE AMS 5931A-2005 Steel Bars Wire Forgings Extrusions Tubing and Rings Wear Galling and Corrosion-Resistant 5 0Mn - 3 5Si - 16 5Cr - 5 0Ni - 0 14N Solution Heat Treated (UNS S2016.pdf SAE AMS 5931A-2005 Steel Bars Wire Forgings Extrusions Tubing and Rings Wear Galling and Corrosion-Resistant 5 0Mn - 3 5Si - 16 5Cr - 5 0Ni - 0 14N Solution Heat Treated (UNS S2016.pdf
  • 相关搜索

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

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