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

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

1、计算机三级数据库技术-85 及答案解析(总分:100.00,做题时间:90 分钟)1.已知文件 IN.DAT 中存有 200 个 4 位数,并已调用读函数 readDat(),把这些数存入数组 a 中。请编写函数 jsVal(),其功能是:依次从数组 a 中取出 4 位数,如果该 4 位数连续小于它以后的 5 个数,且该数是偶数(该 4 位数以后不足 5 个数,则不统计),则统计出满足此条件的数的个数 cnt,并把这些 4 位数按从小到大的顺序存入数组 b 中,最后调用写函数 writeDat(),把结果 cnt 及数组 b 中符合条件的 4 位数输出到 OUT.DAT 文件中。 程序中已定义

2、数组 a200,b200,已定义变量 cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序 #includestdio.h #define MAX 200 int aMAX, bMAX, cnt=0; void writeDat(); void jsVal() void readDat() int i; FILE*fp; fp=fopen(“IN.DAT“, “r“); for(i=0; iMAX; i+) fscanf(fp, “%d“, fclose(fp); void main() int i; readDat(); jsVal

3、); printf(“满足条件的数的个数=%dn“, cnt); for(i=0; icnt; i+) printf(“%d“, bi); printf(“n“); writeDat(); void writeDat() FILE*fp; int i; fp=fopen(“OUT.DAT“, “w“); fprintf(fp, “%dn“, cnt); for(i=0; icnt; i+) fprintf(fp, “%dn“, bi); fclose(fp); (分数:100.00)_计算机三级数据库技术-85 答案解析(总分:100.00,做题时间:90 分钟)1.已知文件 IN.DAT

4、中存有 200 个 4 位数,并已调用读函数 readDat(),把这些数存入数组 a 中。请编写函数 jsVal(),其功能是:依次从数组 a 中取出 4 位数,如果该 4 位数连续小于它以后的 5 个数,且该数是偶数(该 4 位数以后不足 5 个数,则不统计),则统计出满足此条件的数的个数 cnt,并把这些 4 位数按从小到大的顺序存入数组 b 中,最后调用写函数 writeDat(),把结果 cnt 及数组 b 中符合条件的 4 位数输出到 OUT.DAT 文件中。 程序中已定义数组 a200,b200,已定义变量 cnt。请勿改动主函数 main()、读函数 readDat()和写函数

5、 writeDat()的内容。 试题程序 #includestdio.h #define MAX 200 int aMAX, bMAX, cnt=0; void writeDat(); void jsVal() void readDat() int i; FILE*fp; fp=fopen(“IN.DAT“, “r“); for(i=0; iMAX; i+) fscanf(fp, “%d“, fclose(fp); void main() int i; readDat(); jsVal(); printf(“满足条件的数的个数=%dn“, cnt); for(i=0; icnt; i+) pr

6、intf(“%d“, bi); printf(“n“); writeDat(); void writeDat() FILE*fp; int i; fp=fopen(“OUT.DAT“, “w“); fprintf(fp, “%dn“, cnt); for(i=0; icnt; i+) fprintf(fp, “%dn“, bi); fclose(fp); (分数:100.00)_正确答案:()解析:void jsVal() int i, j; /*定义循环控制变量*/ int temp; /*定义数据交换是的暂存变量*/ for(i=0; iMAX-5; i+) /*逐个取每个 4 位数*/

7、if(aiai+1 /*将满足条件的数存入数组 b 中*/ cnt+; /*并统计满足条件的数的个数*/ for(i=0; icnt-1; i+) /*利用选择法对 b 数组中的元素进行从小到大的排序*/ for(j=i+1; jcnt; j+) if(bibj) temp=bi; bi=bj; bj=temp; 考点 本题考查对整数的筛选以及数组排序。考查的知识点主要包括:C 语言循环结构,逻辑表达式,数组排序。 此题属于 4 位数的筛选题型。分析题干要求,本题要求实现 jsVal()函数的功能,归纳可以得出 2 个问题:问题 1 如何通过判断条件(该 4 位数连续小于该 4 位数以后的 5 个数且该数是偶数)筛选出满足条件的数,同时统计其个数;问题 2 如何将这些数按照从小到大的顺序排列。 通过问题分析,得出解此题的思路为:先根据题目中的条件筛选出满足条件的数并存入新的数组中,再对新数组进行排序。对于问题 1 通过 if条件判断语句和逻辑表达式可以实现;问题 2 排序可以通过循环嵌套的起泡法实现。

展开阅读全文
相关资源
猜你喜欢
  • AS NZS 14598 1-2000 Information technology - Software product evaluation - General overview《信息技术 软件产品评价 综述》.pdf AS NZS 14598 1-2000 Information technology - Software product evaluation - General overview《信息技术 软件产品评价 综述》.pdf
  • AS NZS 14598 2-2000 Information technology - Software product evaluation Planning and management《信息技术 软件产品评估的计划和管理》.pdf AS NZS 14598 2-2000 Information technology - Software product evaluation Planning and management《信息技术 软件产品评估的计划和管理》.pdf
  • AS NZS 14598 3-2000 Information technology - Software product evaluation - Process for developers《信息技术 软件产品评估 开发者用的过程》.pdf AS NZS 14598 3-2000 Information technology - Software product evaluation - Process for developers《信息技术 软件产品评估 开发者用的过程》.pdf
  • AS NZS 14598 4-2000 Information technology - Software product evaluation - Process for acquirers《信息技术 软件产品估价 受让人程序》.pdf AS NZS 14598 4-2000 Information technology - Software product evaluation - Process for acquirers《信息技术 软件产品估价 受让人程序》.pdf
  • AS NZS 14598 6-2001 Information technology - Software product evaluation - Documentation of evaluation modules《给水用1 2 In (12 mm)到2 In (50 mm)聚乙烯-铝-聚乙烯和交联聚乙烯-铝-交联聚乙烯复合压力管》.pdf AS NZS 14598 6-2001 Information technology - Software product evaluation - Documentation of evaluation modules《给水用1 2 In (12 mm)到2 In (50 mm)聚乙烯-铝-聚乙烯和交联聚乙烯-铝-交联聚乙烯复合压力管》.pdf
  • AS NZS 1462 1-2006 Methods of test for plastics pipes and fittings - Method for determining the dimensions of pipes and fittings《塑料管及配件测试方法 确定管及配件直径的方法》.pdf AS NZS 1462 1-2006 Methods of test for plastics pipes and fittings - Method for determining the dimensions of pipes and fittings《塑料管及配件测试方法 确定管及配件直径的方法》.pdf
  • AS NZS 1462 13-2006 Methods of test for plastics pipes and fittings - Method for the determination of elastomeric seal joint contact width and pressure《塑料管及配件测试方法 弹性密封件接触宽度和压力的测定方法.pdf AS NZS 1462 13-2006 Methods of test for plastics pipes and fittings - Method for the determination of elastomeric seal joint contact width and pressure《塑料管及配件测试方法 弹性密封件接触宽度和压力的测定方法.pdf
  • AS NZS 1462 16-2006 Methods of test for plastics pipes and fittings - Method for high temperature testing of pipe《塑料管及配件测试方法 管道的高温试验方法》.pdf AS NZS 1462 16-2006 Methods of test for plastics pipes and fittings - Method for high temperature testing of pipe《塑料管及配件测试方法 管道的高温试验方法》.pdf
  • AS NZS 1462 19-2006 Methods of test for plastics pipes and fittings - C-ring test for fracture toughness of PVC pipes《塑料管及配件测试方法 PVC管断裂任性的C环试验》.pdf AS NZS 1462 19-2006 Methods of test for plastics pipes and fittings - C-ring test for fracture toughness of PVC pipes《塑料管及配件测试方法 PVC管断裂任性的C环试验》.pdf
  • 相关搜索

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

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