【计算机类职业资格】计算机三级数据库技术-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 判断结构和逻辑表达式来完成。

展开阅读全文
相关资源
猜你喜欢
  • ONORM EN 29646-1-1992 Information technology - Open Systems Interconnection -Conformance testing methodology and framework -General concepts《信息技术 开放系统互连 一致性试验方法和构架 一般概念》.pdf ONORM EN 29646-1-1992 Information technology - Open Systems Interconnection -Conformance testing methodology and framework -General concepts《信息技术 开放系统互连 一致性试验方法和构架 一般概念》.pdf
  • ONORM EN 29646-2-1992 Information technology - Open Systems Interconnection -Conformance testing methodology and framework -Abstract test suite specification《信息技术 开放系统互连 一致性试验方法和构架.pdf ONORM EN 29646-2-1992 Information technology - Open Systems Interconnection -Conformance testing methodology and framework -Abstract test suite specification《信息技术 开放系统互连 一致性试验方法和构架.pdf
  • ONORM EN 29646-4-1992 Information technology - Open Systems Interconnection -Conformance testing methodology and framework -Test realization《信息技术 开放系统互连 一致性试验方法和构架 测试实现》.pdf ONORM EN 29646-4-1992 Information technology - Open Systems Interconnection -Conformance testing methodology and framework -Test realization《信息技术 开放系统互连 一致性试验方法和构架 测试实现》.pdf
  • ONORM EN 29646-5-1992 Information technology - Open Systems Interconnection -Conformance testing methodology and framework -Requirements on test laboratories and clients for the co.pdf ONORM EN 29646-5-1992 Information technology - Open Systems Interconnection -Conformance testing methodology and framework -Requirements on test laboratories and clients for the co.pdf
  • ONORM EN 29661-1994 Information processing Data interchange on 12 7 mm (0 5 in) magnetic tape cartridges 18 tracks 1491 data bytes per millimetre (37871 data bytes per inch) (ISO I2 19.pdf ONORM EN 29661-1994 Information processing Data interchange on 12 7 mm (0 5 in) magnetic tape cartridges 18 tracks 1491 data bytes per millimetre (37871 data bytes per inch) (ISO I2 19.pdf
  • ONORM EN 297-1996 Gas-fired central heating boilers-Type B11 and B11BS boilers fitted with atmospheric burners of moninal heat input not exceeding 70 kw《燃气集中供暖锅炉 装有标称输入热量不超过70kW的常压.pdf ONORM EN 297-1996 Gas-fired central heating boilers-Type B11 and B11BS boilers fitted with atmospheric burners of moninal heat input not exceeding 70 kw《燃气集中供暖锅炉 装有标称输入热量不超过70kW的常压.pdf
  • ONORM EN 29735-1992 Electronic data interchange for administration commerce and trade (EDIFACT) - Application level syntax rules《行政管理、商业及贸易数据交换(EDIFACT)应用级语法规则》.pdf ONORM EN 29735-1992 Electronic data interchange for administration commerce and trade (EDIFACT) - Application level syntax rules《行政管理、商业及贸易数据交换(EDIFACT)应用级语法规则》.pdf
  • ONORM EN 29775-1993 Small craft Remote steering systems for single outboard motors of 15 kW to 40 kW power (ISO 9775 1990)《小艇 单机功率15KW 40KW弦外发动机的遥控操纵系统(ISO 9775-1990)》.pdf ONORM EN 29775-1993 Small craft Remote steering systems for single outboard motors of 15 kW to 40 kW power (ISO 9775 1990)《小艇 单机功率15KW 40KW弦外发动机的遥控操纵系统(ISO 9775-1990)》.pdf
  • ONORM EN 29787-1992 Manipulating industrial robots - Coordinate systems and motions《操作式工业机器人 坐标系和运动》.pdf ONORM EN 29787-1992 Manipulating industrial robots - Coordinate systems and motions《操作式工业机器人 坐标系和运动》.pdf
  • 相关搜索

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

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