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

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

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

2、cdzaabck.LLhj结果:Aec.Bdeabbcdl.LLik原始数据文件存放的格式是:每行的宽度均小于 80 个字符,含标点符号和空格。注意:部分源程序已给出。请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#includestdio.h#includestring.h#includestdlib.hchar xx5080;int maxline=0;/*文章的总行数*/int ReadDat(void);void WriteDat(void);void ConvertCharA(void)void main()system(“C

3、LS“);if(ReadDat()printf(“数据文件 IN5.DAT 不能打开!/n/007“);return;ConvertCharA();WriteDat();int ReadDat(void)FILE *fp;int i=0;char *p;if(fp=fopen(“IN5.DAT“,“r“)=NULL)return 1;while(fgets(xxi,80,fp)!NULL)P=strehr(xxi,/n);if(P) *P=0;i+;maxline=i;fclose(fp);return 0;void WriteDat(void)FILE *fp;int i;system(“C

4、LS“);fp=fopen(“OUT5.DAT“,“w“);for(i=0;imaxline;i+)prinff(“%s/n“,xxi);fprinff(fp,“%s/n“,xxi);fclose(fp);(分数:100.00)_三级数据库技术机试-197 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是实现从文件 IN5.DAT 中读取一篇英文文章存入到字符串数组 xx 中。请编制函数 ConvertCharA(),该函数的功能是:以行为单位把字符串中的所有小写字母改写成该字母的下一个字母,如果是字母 z,则

5、改写成字母 a。大写字母仍为大写字母,小写字母仍为小写字母,其他字符不变。把已处理的字符串仍按行重新存入字符串数组 xx 中,最后调用函数 WriteDat()把结果 xx 输出到文件OUT5.DAT 中。例如,原文:Adb.Bcdzaabck.LLhj结果:Aec.Bdeabbcdl.LLik原始数据文件存放的格式是:每行的宽度均小于 80 个字符,含标点符号和空格。注意:部分源程序已给出。请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#includestdio.h#includestring.h#includestdlib.hcha

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

7、,fp)!NULL)P=strehr(xxi,/n);if(P) *P=0;i+;maxline=i;fclose(fp);return 0;void WriteDat(void)FILE *fp;int i;system(“CLS“);fp=fopen(“OUT5.DAT“,“w“);for(i=0;imaxline;i+)prinff(“%s/n“,xxi);fprinff(fp,“%s/n“,xxi);fclose(fp);(分数:100.00)_正确答案:(void ConvertCharA(void)int i,j; /*定义循环控制变量*/int str; /*存储字符串的长度*/

8、for(i=0;imaxline;i+) /*以行为单位获取字符*/str=strlen(xxi); /*求得当前行的字符串的长度*/for(j=0;jstr;j+) /*逐个取得当前行的每一个字符*/if(xxij=a /*如果是小写字母 z,则改写成字母 a*/elsexxij+=1; /*其他的小写字母则改写为该字母的下一个字母*/)解析:解析 本题要对二维数组中的字符元素按行进行处理,因此,首先要求得当前行所包含的字符个数,然后可以利用循环来依次访问该行中的所有字符。对于每个字符,先要判断该字符是否小写字母,如果是,则进一步判断该字符是否是小写字母z,若是,则改写为小写字母a;若不是,则将其改成该字母的下一个字母。对于不是小写字母的字符不作处理。

展开阅读全文
相关资源
猜你喜欢
  • GOST R 41 77-1999 Uniform provisions concerning the approval of parking lamps for power-driven vehicles《关于审核机动车辆的停车灯的统一规定》.pdf GOST R 41 77-1999 Uniform provisions concerning the approval of parking lamps for power-driven vehicles《关于审核机动车辆的停车灯的统一规定》.pdf
  • GOST R 41 78-2001 Uniform provisions concerning the type approval of vehicles of category L with regard to braking《关于审核L类车辆刹车装置的统一规定》.pdf GOST R 41 78-2001 Uniform provisions concerning the type approval of vehicles of category L with regard to braking《关于审核L类车辆刹车装置的统一规定》.pdf
  • GOST R 41 79-1999 Uniform provisions concerning the approval of vehicles with regard to steering equipment《关于审核车辆转向装置的统一规定》.pdf GOST R 41 79-1999 Uniform provisions concerning the approval of vehicles with regard to steering equipment《关于审核车辆转向装置的统一规定》.pdf
  • GOST R 41 8-1999 Uniform provisions concerning the approval of motor vehicle headlamps emitting an asymmetrical passing beam (or) a driving beam or both and equipped with halogen f HIR.pdf GOST R 41 8-1999 Uniform provisions concerning the approval of motor vehicle headlamps emitting an asymmetrical passing beam (or) a driving beam or both and equipped with halogen f HIR.pdf
  • GOST R 41 80-1999 Uniform provisions concerning the approval of seats of large passenger vehicles and of these vehicles with regard to the strength of the seats and their anchorage.pdf GOST R 41 80-1999 Uniform provisions concerning the approval of seats of large passenger vehicles and of these vehicles with regard to the strength of the seats and their anchorage.pdf
  • GOST R 41 81-1999 Uniform provisions concerning the approval of rear-view mirrors of two-wheeled power-driven vehicles with or without side car with regard to the mounting of rear-.pdf GOST R 41 81-1999 Uniform provisions concerning the approval of rear-view mirrors of two-wheeled power-driven vehicles with or without side car with regard to the mounting of rear-.pdf
  • GOST R 41 82-1999 Uniform provisions concerning the approval of moped headlamps equipped with filament halogen lamps (HS2)《关于机动脚踏两用车前照灯(配有HS2卤素白炽灯泡)的统一规定》.pdf GOST R 41 82-1999 Uniform provisions concerning the approval of moped headlamps equipped with filament halogen lamps (HS2)《关于机动脚踏两用车前照灯(配有HS2卤素白炽灯泡)的统一规定》.pdf
  • GOST R 41 83-2004 Uniform provisions concerning the approval of vehicles with regard to the emission of pollutants according to engine fuel requirements《关于根据发动机燃料要求审核车辆污染物排放的统一规定》.pdf GOST R 41 83-2004 Uniform provisions concerning the approval of vehicles with regard to the emission of pollutants according to engine fuel requirements《关于根据发动机燃料要求审核车辆污染物排放的统一规定》.pdf
  • GOST R 41 84-1999 Uniform provisions concerning the approval of power-driven vehicles equipped with internal combustion engines with regard to the measurement of fuel consumption《关.pdf GOST R 41 84-1999 Uniform provisions concerning the approval of power-driven vehicles equipped with internal combustion engines with regard to the measurement of fuel consumption《关.pdf
  • 相关搜索

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

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