[计算机类试卷]国家三级(数据库技术)机试模拟试卷23及答案与解析.doc

上传人:fuellot230 文档编号:495295 上传时间:2018-11-28 格式:DOC 页数:4 大小:27.50KB
下载 相关 举报
[计算机类试卷]国家三级(数据库技术)机试模拟试卷23及答案与解析.doc_第1页
第1页 / 共4页
[计算机类试卷]国家三级(数据库技术)机试模拟试卷23及答案与解析.doc_第2页
第2页 / 共4页
[计算机类试卷]国家三级(数据库技术)机试模拟试卷23及答案与解析.doc_第3页
第3页 / 共4页
[计算机类试卷]国家三级(数据库技术)机试模拟试卷23及答案与解析.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家三级(数据库技术)机试模拟试卷 23及答案与解析 一、程序设计题 1 已知数据文件 IN23.DAT中存有 200个 4位数,并已调用读函数 readDat()把这些数存入数组 a中。请编制函数 jsVal(),其功能是:依次从数组 a中取出一个 4位数,如果 4位数连续大于该 4位数以前的 5个数且该数是奇数,该数必须能被 7整除,则统计出满足此条件的数的个数 cnt,并把这些 4位数按从大到小的顺序存入数组 b中,最后调用写函数 writeDat()把结果 cnt及数组 b中符合条件的 4位数输出到 OUT23.DAT文件中。 注意:部分源程序已给出。 程序中已定义数组: a200,

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

3、数 =%dn“, cnt); for(i=0; i cnt; i+) printf(“%d“, bi ); printf(“n“); writeDat(); writeDat() FILE *fp; int i; fP = fopen(“OUT23.DAT“, “w“); fprintf(fp, “%dn“, cnt); for(i=0; i cnt; i+) fprintf(fp, “%dn“, bi ); fclose(fp); 国家三级(数据库技术)机试模拟试卷 23答案与解析 一、程序设计题 1 【正确答案】 void jsVal() int i, j, flag=0; for(i=5

4、 i MAX-5; i+) /*如果 4位数连续大于该数以前的 5个数,则置 flag为 1,否则取下一个数 */ for(j=i-5; j i; j+) if(aiaj) flag=1; else flag=0; break; if(flag=1 cnt+; for(i=0; i cnt-1; i+) /*将数组 b中的数按从大到小的顺序排列 */ for(j=i+1; j cnt; j+) if(bi bj) flag=bi; bi=bj; bj=flag; 【试题解析】 根据题意可知,要编制函数的功能有两部分:一是找出满足条件的4位数,二是对找出的数进行从大到小排序。首先利用一个 for循环来依次从数组中取得 4位数,接着拿当前得到的 4位数与该数前面的连续的 5个数依次进行比较。如果该数比它前面的 5个数都大,则给标志变量 flag赋值 1,接着对 flag进行判断,如果不为 1,则该数肯定不符合条件,直接去取下一个数。若 flag值为 1,再来判断该数是否是奇 数,如果恰好该数又能被 7整除,则把该数添加到数组 b中。这样就可以依次取出符合条件的数。然后利用选择法对数组 b中的元素进行从大到小的排序。

展开阅读全文
相关资源
猜你喜欢
  • ASHRAE 4834-2006 Investigation into Airborne Transport Characteristics of Airflow Due to Coughing in a Stagnant Indoor Environment《因咳嗽在停滞的室内环境引起的气流 空中交通的特点调查》.pdf ASHRAE 4834-2006 Investigation into Airborne Transport Characteristics of Airflow Due to Coughing in a Stagnant Indoor Environment《因咳嗽在停滞的室内环境引起的气流 空中交通的特点调查》.pdf
  • ASHRAE 4835-2006 Mass Generation Rates of Ammonia Moisture and Heat Production in Nouse Cages with Two Bedding Types Two Mouse Strains and Two Room Relative Humidities《有两个寝具类型的笼 两个.pdf ASHRAE 4835-2006 Mass Generation Rates of Ammonia Moisture and Heat Production in Nouse Cages with Two Bedding Types Two Mouse Strains and Two Room Relative Humidities《有两个寝具类型的笼 两个.pdf
  • ASHRAE 4836-2006 Model Predictive Control of Supply Air Temperature and Outside Air Intake Rate of a VAV Air-Handling Unit《某变风量空气处理机组 室外空气摄入率和送风温度模型预测控制》.pdf ASHRAE 4836-2006 Model Predictive Control of Supply Air Temperature and Outside Air Intake Rate of a VAV Air-Handling Unit《某变风量空气处理机组 室外空气摄入率和送风温度模型预测控制》.pdf
  • ASHRAE 4837-2006 Modeling and Testing of a Utility Peak Reducing Residential Hot Dry Air Conditioner (HDAC) Using Microchannel Heat Exchangers《用微通道换热器的高峰减少住宅热 干空调器(hdac)效用建模和测试》.pdf ASHRAE 4837-2006 Modeling and Testing of a Utility Peak Reducing Residential Hot Dry Air Conditioner (HDAC) Using Microchannel Heat Exchangers《用微通道换热器的高峰减少住宅热 干空调器(hdac)效用建模和测试》.pdf
  • ASHRAE 4838-2006 Simulated Influence of Roof Reflectance on the Building Energy Balance in Two Northern Cities《两个北方城市 屋顶反射对建筑物能源平衡的影响模拟》.pdf ASHRAE 4838-2006 Simulated Influence of Roof Reflectance on the Building Energy Balance in Two Northern Cities《两个北方城市 屋顶反射对建筑物能源平衡的影响模拟》.pdf
  • ASHRAE 4839-2006 Smoke Control Through a Double-Skin FaCade Used for Natural Ventilation《通过一个双层皮外墙 采用自然通风烟气控制》.pdf ASHRAE 4839-2006 Smoke Control Through a Double-Skin FaCade Used for Natural Ventilation《通过一个双层皮外墙 采用自然通风烟气控制》.pdf
  • ASHRAE 4840-2006 Study on the Applicability of Combining a Desiccant Cooling System with a Heat Pump in a Hot and Humid Climate《除湿冷却系统与热泵 在炎热和潮湿的气候中相结合适用性研究》.pdf ASHRAE 4840-2006 Study on the Applicability of Combining a Desiccant Cooling System with a Heat Pump in a Hot and Humid Climate《除湿冷却系统与热泵 在炎热和潮湿的气候中相结合适用性研究》.pdf
  • ASHRAE 4841-2006 The Effect of Elbows on the Accuracy of Liquid Flow Measurement with an Insertion Flowmeter《用插入式流量计来测试液体流量测量准确性在管道处的影响》.pdf ASHRAE 4841-2006 The Effect of Elbows on the Accuracy of Liquid Flow Measurement with an Insertion Flowmeter《用插入式流量计来测试液体流量测量准确性在管道处的影响》.pdf
  • ASHRAE 4842-2006 VAV Airflow Sensor Response in Relation to “Poor” Upstream Duct Geometry《变风量空调气流传感器的反应在有关“欠佳”上游管几何(反相1137)》.pdf ASHRAE 4842-2006 VAV Airflow Sensor Response in Relation to “Poor” Upstream Duct Geometry《变风量空调气流传感器的反应在有关“欠佳”上游管几何(反相1137)》.pdf
  • 相关搜索

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

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