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

展开阅读全文
相关资源
猜你喜欢
  • TCVN 7605-2007 Foodstuffs Methods of analysis for the detection of genetically modified organisms and derived products Qualitative nucleic acid based methods《食品 检测转基因生物体和衍生产品的分析方法 .pdf TCVN 7605-2007 Foodstuffs Methods of analysis for the detection of genetically modified organisms and derived products Qualitative nucleic acid based methods《食品 检测转基因生物体和衍生产品的分析方法 .pdf
  • TCVN 7606-2007 Foodstuffs Methods of analysis for the detection of genetically modified organisms and derived products Nucleic acid extraction《食品 检测转基因生物体和衍生产品的分析方法 核酸萃取》.pdf TCVN 7606-2007 Foodstuffs Methods of analysis for the detection of genetically modified organisms and derived products Nucleic acid extraction《食品 检测转基因生物体和衍生产品的分析方法 核酸萃取》.pdf
  • TCVN 7607-2007 Foodstuffs Methods of analysis for the detection of genetically modified organisms and derived products Protein based methods《食品 检测转基因生物体和衍生产品的分析方法 基于蛋白质的方法》.pdf TCVN 7607-2007 Foodstuffs Methods of analysis for the detection of genetically modified organisms and derived products Protein based methods《食品 检测转基因生物体和衍生产品的分析方法 基于蛋白质的方法》.pdf
  • TCVN 7608-2007 Foodstuffs Methods of analysis for the detection of genetically modified organisms and derived products General requirements and definitions《食品 检测转基因生物体和衍生产品的分析方法 通用.pdf TCVN 7608-2007 Foodstuffs Methods of analysis for the detection of genetically modified organisms and derived products General requirements and definitions《食品 检测转基因生物体和衍生产品的分析方法 通用.pdf
  • TCVN 7609-1-2007 Sterile single-use intravascular catheters Part 1 General requirements《一次性使用无菌血管内导管 第1部分 一般要求》.pdf TCVN 7609-1-2007 Sterile single-use intravascular catheters Part 1 General requirements《一次性使用无菌血管内导管 第1部分 一般要求》.pdf
  • TCVN 7609-2-2007 Sterile single-use intravascular catheters Part 2 Angiographic catheters《一次性使用无菌血管内导管 第2部分 血管造影导管》.pdf TCVN 7609-2-2007 Sterile single-use intravascular catheters Part 2 Angiographic catheters《一次性使用无菌血管内导管 第2部分 血管造影导管》.pdf
  • TCVN 7609-3-2007 Sterile single-use intravascular catheters Part 3 Central venous catheters《一次性使用无菌血管内导管 第3部分 中心静脉导管》.pdf TCVN 7609-3-2007 Sterile single-use intravascular catheters Part 3 Central venous catheters《一次性使用无菌血管内导管 第3部分 中心静脉导管》.pdf
  • TCVN 7609-4-2007 Sterile single-use intravascular catheters Part 4 Balloon dilatation catheters《一次性使用无菌血管内导管 第4部分 球囊扩张导管》.pdf TCVN 7609-4-2007 Sterile single-use intravascular catheters Part 4 Balloon dilatation catheters《一次性使用无菌血管内导管 第4部分 球囊扩张导管》.pdf
  • TCVN 7609-5-2007 Sterile single-use intravascular catheters Part 5 Over-needle peripheral catheters《一次性使用无菌血管内导管 第5部分 与针头相连的辅助导管》.pdf TCVN 7609-5-2007 Sterile single-use intravascular catheters Part 5 Over-needle peripheral catheters《一次性使用无菌血管内导管 第5部分 与针头相连的辅助导管》.pdf
  • 相关搜索

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

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