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

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

1、三级数据库技术机试-20 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.文件 IN.DAT 中存有 200 个 4 位整型数,函数 readData()负责将 IN.DAT 中的数据读到数组 inBuf中。请编制一函数 findData(),该函数的功能是:依次从数组 inBuf中取出一个 4 位数,如果 4 位数连续大于该 4 位数前的 5 个数且该数是奇数(该 4 位数以前不满 5 个数,则不统计),该数必须能被 7 整除,则按照从小到大的顺序存入 outBuf中,并用 count 记录下符合条件的数据的个数。函数 writeData

2、)负责将outBuf中的数据输出到文件 OUT.DAT 中,并且在屏幕上输出。注意:部分源程序已给出。程序中已定义数组:inBuf200,outBuf200;已定义变量:count。请勿改动主函数 main()、读函数 readData()和写函数 writeData()的内容。试题程序:#includestdio.h#define MAX 200int inBufMAX,outBufMAX,count=0;void findData()void readData()int i;FILE*fp;fp=fopen(“IN.DAT“,“r“);for(i=0;iMAX;i+)fscanf(fp,

3、d“,inBufi);felose(fp);void writeData()FILE*fp:int i;fp=fopen(“OUT.DAT“,“w“);fprintf(fp,“%d/n“,count);for(i=0;icount;i+)fprintf(fp,“%d/n“,outBufi);fclose(fp);void main()int i;readData();findData();printf(“the count of desired datas=%d/n“,count);for(i=0;icount;i+)printf(“%d/n”,outBufi);printf(“n“);w

4、riteData();(分数:100.00)_三级数据库技术机试-20 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.文件 IN.DAT 中存有 200 个 4 位整型数,函数 readData()负责将 IN.DAT 中的数据读到数组 inBuf中。请编制一函数 findData(),该函数的功能是:依次从数组 inBuf中取出一个 4 位数,如果 4 位数连续大于该 4 位数前的 5 个数且该数是奇数(该 4 位数以前不满 5 个数,则不统计),该数必须能被 7 整除,则按照从小到大的顺序存入 outBuf中,并用 count 记录下符

5、合条件的数据的个数。函数 writeData()负责将outBuf中的数据输出到文件 OUT.DAT 中,并且在屏幕上输出。注意:部分源程序已给出。程序中已定义数组:inBuf200,outBuf200;已定义变量:count。请勿改动主函数 main()、读函数 readData()和写函数 writeData()的内容。试题程序:#includestdio.h#define MAX 200int inBufMAX,outBufMAX,count=0;void findData()void readData()int i;FILE*fp;fp=fopen(“IN.DAT“,“r“);for(

6、i=0;iMAX;i+)fscanf(fp,“%d“,inBufi);felose(fp);void writeData()FILE*fp:int i;fp=fopen(“OUT.DAT“,“w“);fprintf(fp,“%d/n“,count);for(i=0;icount;i+)fprintf(fp,“%d/n“,outBufi);fclose(fp);void main()int i;readData();findData();printf(“the count of desired datas=%d/n“,count);for(i=0;icount;i+)printf(“%d/n”,

7、outBufi);printf(“n“);writeData();(分数:100.00)_正确答案:(void findData()int i,j,temp,flag;count=0;for(i=5;iMAX;i+)/*选出是奇数且连续大于其前 5 项的数*/if(inBufi%2!=0inBufi%7=0)/*如果当前数是奇数且能被 7 整除*/flag=0;for(j=1;j=5;j+)if(inBufi/*如果该数比其前 5 个数中的一个小,则将标志置 1,以示不满足要求*/if(flag=0)outBufcount=inBufi;/*将满足要求的数存入 outBuf 中*/count+

8、 /*将计数器加 1*/for(i=0;icount-1;i+)/*以下是对数据进行从小到大的排序*/for(j=i+1;jcount;j+)if(outBufioutBufj)/*如果第 i 位比它后面的数大*/*则将两者进行交换,也即将更小的数放到第 i 位*/temp=outBufi;outBufi=outBufj;outBufj=temp;)解析:解析 本题考查的主要是数据的奇偶性判断及数据的排序。基本思想是:利用条件 inBufi%2!=0 找出奇数。用该数与其前面的连续 5 个数进行比较,如果有一个数不符合要求(小于或等于后面的数),则可将该数排除,这样便可找出所有符合要求的项;将当前数与其后的各个数相比较,如果当前数比其后的数大,则将两数据进行交换,从而使得前面的数小于后面的数最终达到从小到大排序的目的。

展开阅读全文
相关资源
猜你喜欢
  • EN ISO 5840-3-2013 en Cardiovascular implants - Cardiac valve prostheses - Part 3 Heart valve substitutes implanted by transcatheter techniques《心血管植入物 心脏瓣膜假体 第3部分 通过导管技术植入心脏瓣膜替代品(I.pdf EN ISO 5840-3-2013 en Cardiovascular implants - Cardiac valve prostheses - Part 3 Heart valve substitutes implanted by transcatheter techniques《心血管植入物 心脏瓣膜假体 第3部分 通过导管技术植入心脏瓣膜替代品(I.pdf
  • EN ISO 5845-1-1999 en Technical Drawings - Simplified Representation of the Assembly of Parts with Fasteners - Part 1 General Principles《技术制图 紧固件组合的简单表示法 第1部分 一般原则ISO 5845-1-1995》.pdf EN ISO 5845-1-1999 en Technical Drawings - Simplified Representation of the Assembly of Parts with Fasteners - Part 1 General Principles《技术制图 紧固件组合的简单表示法 第1部分 一般原则ISO 5845-1-1995》.pdf
  • EN ISO 585-1999 en Plastics - Unplasticized Cellulose Acetate - Determination of Moisture Content《塑料 未增塑的乙酸纤维素 水分含量的测定》.pdf EN ISO 585-1999 en Plastics - Unplasticized Cellulose Acetate - Determination of Moisture Content《塑料 未增塑的乙酸纤维素 水分含量的测定》.pdf
  • EN ISO 591-1-2000 en Titanium Dioxide Pigments for Paints - Part 1 Specifications and Methods of Test《色漆用二氧化钛颜料 第1部分 规范和试验方法 ISO 591-1-2000》.pdf EN ISO 591-1-2000 en Titanium Dioxide Pigments for Paints - Part 1 Specifications and Methods of Test《色漆用二氧化钛颜料 第1部分 规范和试验方法 ISO 591-1-2000》.pdf
  • EN ISO 5912-2011 en Camping tents《野营帐篷》.pdf EN ISO 5912-2011 en Camping tents《野营帐篷》.pdf
  • EN ISO 5923-2012 en Equipment for fire protection and fire fighting - Fire extinguishing media - Carbon dioxide《防火和消防用设备 灭火剂 二氧化碳》.pdf EN ISO 5923-2012 en Equipment for fire protection and fire fighting - Fire extinguishing media - Carbon dioxide《防火和消防用设备 灭火剂 二氧化碳》.pdf
  • EN ISO 5943-2006 en Cheese and processed cheese products - Determination of chloride content - Potentiometric titration method《干酪和再制干酪制品 氯含量的测定 电势滴定法 ISO 5943-2006》.pdf EN ISO 5943-2006 en Cheese and processed cheese products - Determination of chloride content - Potentiometric titration method《干酪和再制干酪制品 氯含量的测定 电势滴定法 ISO 5943-2006》.pdf
  • EN ISO 595-2-1994 en Reusable All-Glass or Metal-And-Glass Syringes for Medical Use - Part 2 Design Performance Requirements and Tests《可重复使用的全玻璃或金属 玻璃医用注射器 第2部分 设计 性能要求和试验(ISO 595-.pdf EN ISO 595-2-1994 en Reusable All-Glass or Metal-And-Glass Syringes for Medical Use - Part 2 Design Performance Requirements and Tests《可重复使用的全玻璃或金属 玻璃医用注射器 第2部分 设计 性能要求和试验(ISO 595-.pdf
  • EN ISO 5961-1995 en Water Quality - Determination of Cadmium by Atomic Absorption Spectrometry《水质 原子吸收光谱法对镉测定(ISO 5961-1994)》.pdf EN ISO 5961-1995 en Water Quality - Determination of Cadmium by Atomic Absorption Spectrometry《水质 原子吸收光谱法对镉测定(ISO 5961-1994)》.pdf
  • 相关搜索

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

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