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

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

1、计算机三级数据库技术-126 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是从文件 IN.DAT 中读取一篇英文文章存入到字符串数组 xx 中。请编写函数StrOR(),该函数的功能是:以行为单位把字符串中所有小写字母“o”左边的字符串内容移至该串的右边存放,然后把小写字母“o”删除,余下的字符串内容移到已处理字符串的左边存放,最后把已处理的字符串仍按行重新存入字符串数组 xx 中。最后调用函数 writeDat(),把结果输出到文件 OUT.DAT 中。 例如,原文:You can create an i

2、ndex on any field you have the correct record 结果:n any field Yu can create an index rd yu have the crrect rec 原始数据文件存放的格式是:每行的宽度均小于 80 个字符(含标点符号和空格)。 注意:请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。 【试题程序】 #include stdio.h #include string.h #include stdlib.h char xx5080; int maxline =0 ; int ReadD

3、at (void) ; void WriteDat (void) ; void StrOR (void) void main () system (“CLS“) ; if (Readmat () printf (“数据文件 IN.DAT 无法打开! n007“) ; return; StrOR () ; 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) !

4、NULL) p =strchr (xxi,“n“) ; if (p) *p =0; i+; maxline = i ; fclose (fp) ; return 0 ; void Writemat (void) FILE * fp; int i ; system (“CLS“) ; fp = fopen ( “OUT. DAT“, “w“ ) ; for (i =0;i maxline;i +) printf (“%sn“, xxi ) ; fprintf (fp, “%s n“, xxi ) ; fclose (fp) ; (分数:100.00)_计算机三级数据库技术-126 答案解析(总

5、分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是从文件 IN.DAT 中读取一篇英文文章存入到字符串数组 xx 中。请编写函数StrOR(),该函数的功能是:以行为单位把字符串中所有小写字母“o”左边的字符串内容移至该串的右边存放,然后把小写字母“o”删除,余下的字符串内容移到已处理字符串的左边存放,最后把已处理的字符串仍按行重新存入字符串数组 xx 中。最后调用函数 writeDat(),把结果输出到文件 OUT.DAT 中。 例如,原文:You can create an index on any field you

6、have the correct record 结果:n any field Yu can create an index rd yu have the crrect rec 原始数据文件存放的格式是:每行的宽度均小于 80 个字符(含标点符号和空格)。 注意:请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。 【试题程序】 #include stdio.h #include string.h #include stdlib.h char xx5080; int maxline =0 ; int ReadDat (void) ; void Write

7、Dat (void) ; void StrOR (void) void main () system (“CLS“) ; if (Readmat () printf (“数据文件 IN.DAT 无法打开! n007“) ; return; StrOR () ; 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,

8、n“) ; if (p) *p =0; i+; maxline = i ; fclose (fp) ; return 0 ; void Writemat (void) FILE * fp; int i ; system (“CLS“) ; fp = fopen ( “OUT. DAT“, “w“ ) ; for (i =0;i maxline;i +) printf (“%sn“, xxi ) ; fprintf (fp, “%s n“, xxi ) ; fclose (fp) ; (分数:100.00)_正确答案:()解析:void StrOR(void) int i,j,k; /*定义循

9、环控制变量*/ int index,str; /*定义变量*/ char temp; /*暂存变量*/ for(i=0;imaxline;i+) /*逐行获取字符数据进行处理*/ str=strlen(xxi); /*求各行的长度*/ index=str; for(j=0;jstr;j+) /*将一行中所以小写字母 o 右边的字符依次向左移一位,并删除字母 o*/ if(xxij=“o“) for(k=j;kstr-1;k+) xxik=xxik+1; xxistr-1=“ “; index=j; /*记录下最后一个 o 所在的位置*/ j = 0; for(j=str-1;j=index;j

10、) /*最后一个 o 右侧的所有字符都移到已处理字符串的左边*/ temp=xxistr-1; for(k=str-1;k0;k-) xxik=xxik-1; xxi0=temp; 考点 本题考查对字符串处理。考查的知识点主要包括:字符串元素的遍历访问, if 判断结构,逻辑表达式。 解析 本题的解题思路是,首先确定该行字符串的长度;然后使用循环结构依次对字符进行处理;先找到字符“o“,将“o“右侧的字符依次向左移,这个操作同时能够删除字符“o“。记录下最后一个“o“所在的位置,在这个“o“右侧的所有字符都要移到已处理字符串的左边,这个过程也是使用循环来完成的。 对字符数组进行逐元素访问;if 判断结构中的逻辑表达式。

展开阅读全文
相关资源
猜你喜欢
  • EN 62021-3-2014 en Insulating liquids - Determination of acidity - Part 3 Test methods for non mineral insulating oils.pdf EN 62021-3-2014 en Insulating liquids - Determination of acidity - Part 3 Test methods for non mineral insulating oils.pdf
  • EN 62022-2007 en Installed monitors for the control and detection of gamma radiations contained in recyclable or non-recyclable materials transported by vehicles《由车辆运输的可再利用或不可再利用材料.pdf EN 62022-2007 en Installed monitors for the control and detection of gamma radiations contained in recyclable or non-recyclable materials transported by vehicles《由车辆运输的可再利用或不可再利用材料.pdf
  • EN 62023-2012 en Structuring of technical information and documentation (Incorporating corrigendum February 2012)《技术资料和文献的结构(包括2012年2月勘误表)》.pdf EN 62023-2012 en Structuring of technical information and documentation (Incorporating corrigendum February 2012)《技术资料和文献的结构(包括2012年2月勘误表)》.pdf
  • EN 62024-1-2008 en High frequency inductive components - Electrical characteristics and measuring methods - Part 1 Nanohenry range chip inductor《高频感应元件 电气特性和测量方法 第1部分 毫微亨利芯片感应器》.pdf EN 62024-1-2008 en High frequency inductive components - Electrical characteristics and measuring methods - Part 1 Nanohenry range chip inductor《高频感应元件 电气特性和测量方法 第1部分 毫微亨利芯片感应器》.pdf
  • EN 62024-2-2009 en High frequency inductive components - Electrical characteristics and measuring methods - Part 2 Rated current of inductors for DC to DC converters《高频感应元件 电气特性和测量.pdf EN 62024-2-2009 en High frequency inductive components - Electrical characteristics and measuring methods - Part 2 Rated current of inductors for DC to DC converters《高频感应元件 电气特性和测量.pdf
  • EN 62025-1-2007 en High frequency inductive components - Non-electrical characteristics and measuring methods - Part 1 Fixed surface mounted inductors for use in electronic and tel.pdf EN 62025-1-2007 en High frequency inductive components - Non-electrical characteristics and measuring methods - Part 1 Fixed surface mounted inductors for use in electronic and tel.pdf
  • EN 62025-2-2005 en High frequency inductive components Non-electrical characteristics and measuring methods Part 2 Test methods for non-electrical characteristics《高频感应元件 非电气特性和测量方法.pdf EN 62025-2-2005 en High frequency inductive components Non-electrical characteristics and measuring methods Part 2 Test methods for non-electrical characteristics《高频感应元件 非电气特性和测量方法.pdf
  • EN 62026-1-2007 en Low-voltage switchgear and controlgear - Controller-device interfaces (CDIs) - Part 1 General rules《低压开关设备和控制设备 控制器接口(CDIs) 第1部分 总则》.pdf EN 62026-1-2007 en Low-voltage switchgear and controlgear - Controller-device interfaces (CDIs) - Part 1 General rules《低压开关设备和控制设备 控制器接口(CDIs) 第1部分 总则》.pdf
  • EN 62026-2-2013 en Low-voltage switchgear and controlgear - Controller-device interfaces (CDIs) - Part 2 Actuator sensor interface (AS-i).pdf EN 62026-2-2013 en Low-voltage switchgear and controlgear - Controller-device interfaces (CDIs) - Part 2 Actuator sensor interface (AS-i).pdf
  • 相关搜索

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

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