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

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

1、计算机三级数据库技术-114 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 readDat()的功能是从文件 IN.DAT中读取 20行数据存放到字符串数组 xx中(每行字符串长度均小于 80)。请编写函数 jsSort(),该函数的功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组 xx中,最后调用函数 writeDat(),把结果 xx输出到文件 OUT.DAT中。 条件:从字符串中间一分为二,左半部分按字符的 ASCII码值降序排序,排序后,左半部分与右半部分按例子所示的方法进行交换。如果

2、原字符串长度为奇数,则最中间的字符不予处理,字符仍放在原位置上。 例如,位置 0 1 2 3 4 5 6 7 8 原字符串 a b c d h g f e 2 3 4 9 8 7 6 5 处理后 h g f e d c b a 8 7 6 5 9 4 3 2 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序 #includestdio.h #includestring.h #includestdlib.h char xx2080; void readDat(); void writeDat(); void jsSort() void ma

3、in() readDat(); jsSort(); writeDat(); void readDat() FILE*in; int i=0; char*p; in=fopen(“IN.DAT“,“r“); while(i20fgets(xxi,80,in)! =NULL) P=strchr(xxi,“n“); if(P) *P=0; i+; fclose(in); void writeDat() FILE*out; int i; system(“CLS“); out=fopen(“OUT.DAT“,“w“); for(i=0; i20; i+) printf(“%sn“,xxi); fprin

4、tf(out,“%sn“,xxi); fclose(out); (分数:100.00)_计算机三级数据库技术-114 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 readDat()的功能是从文件 IN.DAT中读取 20行数据存放到字符串数组 xx中(每行字符串长度均小于 80)。请编写函数 jsSort(),该函数的功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组 xx中,最后调用函数 writeDat(),把结果 xx输出到文件 OUT.DAT中。 条件:从字符串中间一分为二,左半部分按字

5、符的 ASCII码值降序排序,排序后,左半部分与右半部分按例子所示的方法进行交换。如果原字符串长度为奇数,则最中间的字符不予处理,字符仍放在原位置上。 例如,位置 0 1 2 3 4 5 6 7 8 原字符串 a b c d h g f e 2 3 4 9 8 7 6 5 处理后 h g f e d c b a 8 7 6 5 9 4 3 2 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序 #includestdio.h #includestring.h #includestdlib.h char xx2080; void readDa

6、t(); void writeDat(); void jsSort() void main() readDat(); jsSort(); writeDat(); void readDat() FILE*in; int i=0; char*p; in=fopen(“IN.DAT“,“r“); while(i20fgets(xxi,80,in)! =NULL) P=strchr(xxi,“n“); if(P) *P=0; i+; fclose(in); void writeDat() FILE*out; int i; system(“CLS“); out=fopen(“OUT.DAT“,“w“);

7、 for(i=0; i20; i+) printf(“%sn“,xxi); fprintf(out,“%sn“,xxi); fclose(out); (分数:100.00)_正确答案:()解析:void jsSort() int i,j,k; /*定义计数器变量*/ int str,half; /*定义存储字符串长度的变量*/ char temp; /*定义数据交换时的暂存变量*/ for(i=0;i20;i+) /*逐行对数据进行处理*/ str=strlen(xxi); /*求字符串的长度*/ half=str/2; /*通过 half将字符串分为左右两部分*/ for(j=0;jhalf

8、1;j+) /*用选择法将左边部分按字符的 ASCII值降序排序*/ for(k=j+1;khalf;k+) if(xxijxxik) temp=xxij; xxij=xxik; xxik=temp; for(j=half-1,k=str-1;j=0;j-,k-) /*将左边部分和右边部分的对应字符交换*/ temp=xxij; xxij=xxik; xxik=temp; 考点 本题考查对整数的筛选以及数组排序。考查的知识点主要包括:循环嵌套,数组排序。 本题属于字符串操作类题;考查对二维字符数组的处理。 本题解题思路:需要首先求得各行字符串的长度(利用求字符串长度的 strlen()函数),然后借助循环结构逐个访问各行中的每一个字符。 在本题中,应先确定各行中字符串的中间位置,之后用起泡法先对中间位置以前的字符进行降序排序。接着把中间位置前的一个位置定为初始位置,字符串中的最后一个位置也视为初始位置,使两个位置所对应的字符进行交换,交换过后,这两个位置值(也就是下标值)分别前移,再进行对应位置字符的交换。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN ISO 16498-2013 Dentistry - Minimal dental implant data set for clinical use (ISO 16498 2013) German version EN ISO 16498 2013《牙科学 临床应用最小的牙科植体数据集(ISO 16498-2013) 德文版本EN ISO 1.pdf DIN EN ISO 16498-2013 Dentistry - Minimal dental implant data set for clinical use (ISO 16498 2013) German version EN ISO 16498 2013《牙科学 临床应用最小的牙科植体数据集(ISO 16498-2013) 德文版本EN ISO 1.pdf
  • DIN EN ISO 16558-1-2015 Soil quality - Risk-based petroleum hydrocarbons - Part 1 Determination of aliphatic and aromatic fractions of volatile petroleum hydrocarbons using gas chr.pdf DIN EN ISO 16558-1-2015 Soil quality - Risk-based petroleum hydrocarbons - Part 1 Determination of aliphatic and aromatic fractions of volatile petroleum hydrocarbons using gas chr.pdf
  • DIN EN ISO 16559-2014 Solid biofuels - Terminology definitions and descriptions (ISO 16559 2014) German version EN ISO 16559 2014《固体生物燃料 术语 定义和描述(ISO 16559-2014) 德文版本EN ISO 16559-2.pdf DIN EN ISO 16559-2014 Solid biofuels - Terminology definitions and descriptions (ISO 16559 2014) German version EN ISO 16559 2014《固体生物燃料 术语 定义和描述(ISO 16559-2014) 德文版本EN ISO 16559-2.pdf
  • DIN EN ISO 16582-2003 Open end blind rivets with break pull mandrel and protruding head - Cu St or Cu Br or Cu SSt (ISO 16582 2002) German version EN ISO 16582 2002《开口型盘头抽芯盲铆钉 Cu S.pdf DIN EN ISO 16582-2003 Open end blind rivets with break pull mandrel and protruding head - Cu St or Cu Br or Cu SSt (ISO 16582 2002) German version EN ISO 16582 2002《开口型盘头抽芯盲铆钉 Cu S.pdf
  • DIN EN ISO 16583-2003 Open end blind rivets with break pull mandrel and countersunk head - Cu St or Cu Br or Cu SSt (ISO 16583 2002) German version EN ISO 16583 2002《开口型沉头抽芯盲铆钉 Cu .pdf DIN EN ISO 16583-2003 Open end blind rivets with break pull mandrel and countersunk head - Cu St or Cu Br or Cu SSt (ISO 16583 2002) German version EN ISO 16583 2002《开口型沉头抽芯盲铆钉 Cu .pdf
  • DIN EN ISO 16584-2003 Open end blind rivets with break pull mandrel and protruding head - NiCu St or NiCi SSt (ISO 16584 2002) German version EN ISO 16584 2002《开口型盘头抽芯盲铆钉 NiCu St或N.pdf DIN EN ISO 16584-2003 Open end blind rivets with break pull mandrel and protruding head - NiCu St or NiCi SSt (ISO 16584 2002) German version EN ISO 16584 2002《开口型盘头抽芯盲铆钉 NiCu St或N.pdf
  • DIN EN ISO 16585-2003 Closed end blind rivets with break pull mandrel and protruding head - A2 SSt (ISO 16585 2002) German version EN ISO 16585 2002《封闭型盘头抽芯盲铆钉 A2 SSt》.pdf DIN EN ISO 16585-2003 Closed end blind rivets with break pull mandrel and protruding head - A2 SSt (ISO 16585 2002) German version EN ISO 16585 2002《封闭型盘头抽芯盲铆钉 A2 SSt》.pdf
  • DIN EN ISO 16588-2004 Water quality - Determination of six complexing agents - Gas-chromatographic method (ISO 16588 2002) German version EN ISO 16588 2003《水质 六络合反应物的测定 气相色谱法》.pdf DIN EN ISO 16588-2004 Water quality - Determination of six complexing agents - Gas-chromatographic method (ISO 16588 2002) German version EN ISO 16588 2003《水质 六络合反应物的测定 气相色谱法》.pdf
  • DIN EN ISO 16591-2011 Petroleum products - Determination of sulfur content - Oxidative microcoulometry method (ISO 16591 2010) German version EN ISO 16591 2010《石油产品 硫含量测定 氧化微库仑分析法(.pdf DIN EN ISO 16591-2011 Petroleum products - Determination of sulfur content - Oxidative microcoulometry method (ISO 16591 2010) German version EN ISO 16591 2010《石油产品 硫含量测定 氧化微库仑分析法(.pdf
  • 相关搜索

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

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