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

展开阅读全文
相关资源
猜你喜欢
  • NBN-EN ISO 2870-1995 5625 Surface active agents - Detergents - Determination of anionic-active matter hydrolyzable and non- hydrolyzable under acid conditions (ISO 2870 1986)《表面活性剂.pdf NBN-EN ISO 2870-1995 5625 Surface active agents - Detergents - Determination of anionic-active matter hydrolyzable and non- hydrolyzable under acid conditions (ISO 2870 1986)《表面活性剂.pdf
  • NBN-EN ISO 2871-1-1995 9375 《表面活性剂 洗衣粉 活性阳离子含量的测定 第1部分:大分子量活性阳离子(ISO 2871-1-1988)》.pdf NBN-EN ISO 2871-1-1995 9375 《表面活性剂 洗衣粉 活性阳离子含量的测定 第1部分:大分子量活性阳离子(ISO 2871-1-1988)》.pdf
  • NBN-EN ISO 3188-1994 6250 Starches and derived products - Determination of nitrogen content by the Kjeldahl method - Titrimetric method (ISO 3188 1978)《淀粉及其制品 用克耶达(Kjeldahl)法测定含氮量 .pdf NBN-EN ISO 3188-1994 6250 Starches and derived products - Determination of nitrogen content by the Kjeldahl method - Titrimetric method (ISO 3188 1978)《淀粉及其制品 用克耶达(Kjeldahl)法测定含氮量 .pdf
  • NBN-EN ISO 3593-1994 5625 Starch - Determination of ash (ISO 3593 1981)《淀粉 灰分的测定(ISO 3593-1981)》.pdf NBN-EN ISO 3593-1994 5625 Starch - Determination of ash (ISO 3593 1981)《淀粉 灰分的测定(ISO 3593-1981)》.pdf
  • NBN-EN ISO 3946-1994 1875 Starches and derived products - Determination of total phosphorus content - Spectrophotometric method (ISO 3946 1982)《淀粉及其制品磷总含量的测定 分光光度法(ISO 3946-1982)》.pdf NBN-EN ISO 3946-1994 1875 Starches and derived products - Determination of total phosphorus content - Spectrophotometric method (ISO 3946 1982)《淀粉及其制品磷总含量的测定 分光光度法(ISO 3946-1982)》.pdf
  • NBN-EN ISO 3947-1994 1875 Starches native or modified - Determination of total fat content (ISO 3947 1977)《天然或加工淀粉的脂肪总含量的测定(ISO 3947-1977)》.pdf NBN-EN ISO 3947-1994 1875 Starches native or modified - Determination of total fat content (ISO 3947 1977)《天然或加工淀粉的脂肪总含量的测定(ISO 3947-1977)》.pdf
  • NBN-EN ISO 5377-1994 6875 Starch hydrolysis products - Determination of reducing power and dextrose equivalent - Lane and Eynon constant titre method (ISO 5377 1981)《阿米酮或淀粉的水解产品 还原.pdf NBN-EN ISO 5377-1994 6875 Starch hydrolysis products - Determination of reducing power and dextrose equivalent - Lane and Eynon constant titre method (ISO 5377 1981)《阿米酮或淀粉的水解产品 还原.pdf
  • NBN-EN ISO 5378-1994 1250 Starches and derived products - Determination of nitrogen content by the Kjeldahl method - Spectrophotometric method (ISO 5378 1978)《阿米酮,淀粉和衍生品 根据凯氏定氮法测定氮.pdf NBN-EN ISO 5378-1994 1250 Starches and derived products - Determination of nitrogen content by the Kjeldahl method - Spectrophotometric method (ISO 5378 1978)《阿米酮,淀粉和衍生品 根据凯氏定氮法测定氮.pdf
  • NBN-EN ISO 5381-1994 5625 Starch hydrolysis products - Determination of water content - Modified Karl Fischer method (ISO 5381 1983)《阿米酮或淀粉的水解产品 水的配量 修改版卡氏水分测定法(ISO 5381-1983)》.pdf NBN-EN ISO 5381-1994 5625 Starch hydrolysis products - Determination of water content - Modified Karl Fischer method (ISO 5381 1983)《阿米酮或淀粉的水解产品 水的配量 修改版卡氏水分测定法(ISO 5381-1983)》.pdf
  • 相关搜索

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

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