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

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

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

2、eab bcdl.LLik 原始数据文件存放的格式是:每行的宽度均小于 80 个字符(含标点符号和空格)。 请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。 试题程序 #includestdio.h #includestring.h #includestdlib.h char xx5080; int maxline=0; /文章的总行数 int ReadDat(void); void WriteDat(void); void ConvertCharA(void) void main() system(“CLS“); if(ReadDat() pri

3、ntf(“数据文件 IN.DAT 无法打开!n007“); return; ConvertCharA(); WriteDat(); int ReadDat(void) 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(“CL

4、S“); fp=fopen(“OUT.DAT“, “w“); for(i=0; imaxline; i+) printf(“%sn“, xxi); fprintf(fp, “%sn“, xxi); fclose(fp); (分数:100.00)_计算机三级数据库技术-95 答案解析(总分:100.00,做题时间:90 分钟)1.函数 ReadDat()的功能是从文件 IN.DAT 中读取一篇英文文章,存入到字符串数组 xx 中。请编写函数ConvertCharA(),该函数的功能是:以行为单位把字符串中的所有小写字母替换成该字母的下一个字母,如果是字母 z,则替换成字母 a。大写字母仍为大写字

5、母,小写字母仍为小写字母,其他字符不变。把已处理的字符串仍按行重新存入字符串数组 xx 中,最后调用函数 WriteDat(),把结果 XX 输出到文件OUT.DAT 中。 例如,原文:Adb.Bcdza abck.LLhj 结果:Aec.Bdeab bcdl.LLik 原始数据文件存放的格式是:每行的宽度均小于 80 个字符(含标点符号和空格)。 请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。 试题程序 #includestdio.h #includestring.h #includestdlib.h char xx5080; int maxl

6、ine=0; /文章的总行数 int ReadDat(void); void WriteDat(void); void ConvertCharA(void) void main() system(“CLS“); if(ReadDat() printf(“数据文件 IN.DAT 无法打开!n007“); return; ConvertCharA(); WriteDat(); int ReadDat(void) FILE*fp; int i=0; char*p; if(fp=fopen(“IN.DAT“, “r“)=NULL) return 1; while(fgets(xxi, 80, fp)!

7、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“); for(i=0; imaxline; i+) printf(“%sn“, xxi); fprintf(fp, “%sn“, xxi); fclose(fp); (分数:100.00)_正确答案:()解析:void ConvertCharA(void) int i, j; /*定义循环控制变量*

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

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 136000-1993 Generic specification magnetrons German version EN 136000 1992《总规范 磁控管》.pdf DIN EN 136000-1993 Generic specification magnetrons German version EN 136000 1992《总规范 磁控管》.pdf
  • DIN EN 136001-1993 Blank detail specification pulsed magnetrons (excluding frequency agile magnetrons) German version EN 136001 1992《空白详细规范 脉冲磁控管(不包括频率捷变磁控管)》.pdf DIN EN 136001-1993 Blank detail specification pulsed magnetrons (excluding frequency agile magnetrons) German version EN 136001 1992《空白详细规范 脉冲磁控管(不包括频率捷变磁控管)》.pdf
  • DIN EN 136002-1993 Blank detail specification C W magnetrons for RF heating or cooking applications German version EN 136002 1992《空白详细规范 高频加热或烹调用 C W 磁控管》.pdf DIN EN 136002-1993 Blank detail specification C W magnetrons for RF heating or cooking applications German version EN 136002 1992《空白详细规范 高频加热或烹调用 C W 磁控管》.pdf
  • DIN EN 137000-1998 Generic specification - Fixed aluminium electrolytic a c capacitors with non-solid electrolyte for use with motors German version EN 137000 1997《总规范 配合电动机使用的非固态电.pdf DIN EN 137000-1998 Generic specification - Fixed aluminium electrolytic a c capacitors with non-solid electrolyte for use with motors German version EN 137000 1997《总规范 配合电动机使用的非固态电.pdf
  • DIN EN 137100-1998 Sectional specification - Fixed aluminium electrolytic a c capacitors with non-solid electrolyte for motor starter applications - Qualification approval German v.pdf DIN EN 137100-1998 Sectional specification - Fixed aluminium electrolytic a c capacitors with non-solid electrolyte for motor starter applications - Qualification approval German v.pdf
  • DIN EN 137101-1998 Blank detail specification - Fixed aluminium electrolytic a c capacitors with non-solid electrolyte for motor starter applications - Qualification approval Germa.pdf DIN EN 137101-1998 Blank detail specification - Fixed aluminium electrolytic a c capacitors with non-solid electrolyte for motor starter applications - Qualification approval Germa.pdf
  • DIN EN 140101-2008 Blank Detail Specification Fixed low power film resistors German version EN 140101 2008《空白详细规范 固定式低功率薄膜电阻器》.pdf DIN EN 140101-2008 Blank Detail Specification Fixed low power film resistors German version EN 140101 2008《空白详细规范 固定式低功率薄膜电阻器》.pdf
  • DIN EN 140101-806-2014 Detail Specification Fixed low power film resistors - Metal film resistors on high grade ceramic conformal coated or molded axial or preformed leads German v.pdf DIN EN 140101-806-2014 Detail Specification Fixed low power film resistors - Metal film resistors on high grade ceramic conformal coated or molded axial or preformed leads German v.pdf
  • DIN EN 140102-1996 Blank detail specification Fixed low power non-wirewound resistors - Assessment level M German version EN 140102 1996《空白详细规范 低功率非绕线固定电阻 评定等级 M》.pdf DIN EN 140102-1996 Blank detail specification Fixed low power non-wirewound resistors - Assessment level M German version EN 140102 1996《空白详细规范 低功率非绕线固定电阻 评定等级 M》.pdf
  • 相关搜索

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

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