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

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

1、三级数据库技术机试-98 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN.dat 中存有 200 个四位数,并已调用读函数 Rdata()把这些数存入数组 a 中,请编写函数 diffCal(),其功能是:把一个四位数的个位数字上的值减去千位数字上的值,再减去百位数字上的值,最后减去十位数字上的值,如果得出的值大于等于 0 且原四位数是偶数,则统计出满足此条件的数的个数 count,并把这些四位数按从小到大的顺序存入数组 b 中。最后调用写函数 Wdata(),把结果 count以及数组 b 中符合条件的四位数输出到 O

2、UT.dat 文件中。注意:部分源程序已经给出。程序中已定义数组 a200、b200,已定义变量 count。请勿改动数据文件IN.dat 中的任何数据、主函数 main()、读函数 Rdata()和写函数 Wdata()的内容。#include stdio.h#define MAX 200int aMAX, bMAX, count = 0;void diffCal()void Rdata ()int i;FILE *fp;fp = fopen(“IN. dat“, “r“);for (i=0; iMAX; i+)fscanf(fp, “%d,“, fclose (fp);void Wdata

3、 ()FILE *fp;int i;fp = fopen(“OUT. dat“, “w“);fprintf(fp, “%d/n“, count);for (i=0; icount; i+)fprintf(fp, “%d/n“, bi);fclose (fp);void main ()int i;Rdata ();diffCal();printf(“满足条件的数=%d/n“, count);for (i=0; icount; i+)printf(“%d “, bi);printf (“/n“);Wdata ();(分数:100.00)_三级数据库技术机试-98 答案解析(总分:100.00,做题

4、时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN.dat 中存有 200 个四位数,并已调用读函数 Rdata()把这些数存入数组 a 中,请编写函数 diffCal(),其功能是:把一个四位数的个位数字上的值减去千位数字上的值,再减去百位数字上的值,最后减去十位数字上的值,如果得出的值大于等于 0 且原四位数是偶数,则统计出满足此条件的数的个数 count,并把这些四位数按从小到大的顺序存入数组 b 中。最后调用写函数 Wdata(),把结果 count以及数组 b 中符合条件的四位数输出到 OUT.dat 文件中。注意:部分源程序已经给出。程序中已定义数

5、组 a200、b200,已定义变量 count。请勿改动数据文件IN.dat 中的任何数据、主函数 main()、读函数 Rdata()和写函数 Wdata()的内容。#include stdio.h#define MAX 200int aMAX, bMAX, count = 0;void diffCal()void Rdata ()int i;FILE *fp;fp = fopen(“IN. dat“, “r“);for (i=0; iMAX; i+)fscanf(fp, “%d,“, fclose (fp);void Wdata ()FILE *fp;int i;fp = fopen(“O

6、UT. dat“, “w“);fprintf(fp, “%d/n“, count);for (i=0; icount; i+)fprintf(fp, “%d/n“, bi);fclose (fp);void main ()int i;Rdata ();diffCal();printf(“满足条件的数=%d/n“, count);for (i=0; icount; i+)printf(“%d “, bi);printf (“/n“);Wdata ();(分数:100.00)_正确答案:(void diffCal() int i, thou, hun, ten, data, j;for (i=0;

7、 iMAX; i+) thou = ai/1000;hun = ai%1000/100;ten = ai%100/10;data = ai%10;if (data-thou-hun-ten=0 count+;for (i=0; icount-1; i+)for (j=i+1; jcount; j+)if (bi bj) data = bi;bi = bj;bj = data;)解析:解题思路 对于一个四位数,用这个四位数除以 1000,可得到这个四位数千位上的数字输给变量thou:这个四位数对 1000 求余然后再除以 100,可得到这个四位数百位上的数字输给变量 hun:这个四位数对 100 求余然后再除以 10,可得到这个四位数十位上的数字输给变量 ten;这个四位数对 10 求余,可得到这个四位数个位上的数字输给变量 data。然后判断表达式 data-thou-hun-ten=0 & ai%2!=1 是否成立,如果成立,则把这个数赋给数组 b,同时计数变量 count 加 1。最后利用双重循环对数组 b 按数组元素从小到大的顺序排序。

展开阅读全文
相关资源
猜你喜欢
  • EN 1744-8-2012 en Tests for chemical properties of aggregates - Part 8 Sorting test to determine metal content of Municipal Incinerator Bottom Ash (MIBA) Aggregates《集料化学性能的试验 第8部分 .pdf EN 1744-8-2012 en Tests for chemical properties of aggregates - Part 8 Sorting test to determine metal content of Municipal Incinerator Bottom Ash (MIBA) Aggregates《集料化学性能的试验 第8部分 .pdf
  • EN 1745-2012 en Masonry and masonry products - Methods for determining thermal properties《砖石工程和砖石工程产品 测定设计热值的方法》.pdf EN 1745-2012 en Masonry and masonry products - Methods for determining thermal properties《砖石工程和砖石工程产品 测定设计热值的方法》.pdf
  • EN 1746-1998 en Safety of Machinery - Guidance for the Drafting of the Noise Clauses of Safety Standards《机器的安全性 拟定安全标准中有关噪音的章节的指南》.pdf EN 1746-1998 en Safety of Machinery - Guidance for the Drafting of the Noise Clauses of Safety Standards《机器的安全性 拟定安全标准中有关噪音的章节的指南》.pdf
  • EN 1748-1-1-2004 en Glass in building - Special basic products -Borosilicate glasses - Part 1-1 Definition and general physical and mechanical properties《建筑玻璃 特种基础产品 硼硅酸盐玻璃 第1-1部分 .pdf EN 1748-1-1-2004 en Glass in building - Special basic products -Borosilicate glasses - Part 1-1 Definition and general physical and mechanical properties《建筑玻璃 特种基础产品 硼硅酸盐玻璃 第1-1部分 .pdf
  • EN 1748-1-2-2004 en Glass in building - Special basic products -Borosilicate glasses - Part 1-2 Evaluation of conformity Product standard《建筑玻璃 特种基础产品 硼硅酸盐玻璃 第1-2部分 合格评价/产品标准》.pdf EN 1748-1-2-2004 en Glass in building - Special basic products -Borosilicate glasses - Part 1-2 Evaluation of conformity Product standard《建筑玻璃 特种基础产品 硼硅酸盐玻璃 第1-2部分 合格评价/产品标准》.pdf
  • EN 1748-2-1-2004 en Glass in building - Special basic products - Glass ceramics - Part 2-1 Definitions and general physical and mechanical properties《建筑玻璃 特种基础产品 玻璃陶瓷 第2-1部分 定义和一般物.pdf EN 1748-2-1-2004 en Glass in building - Special basic products - Glass ceramics - Part 2-1 Definitions and general physical and mechanical properties《建筑玻璃 特种基础产品 玻璃陶瓷 第2-1部分 定义和一般物.pdf
  • EN 1748-2-2-2004 en Glass in building - Special basic products - Part 2-2 Glass ceramics - Evaluation of conformity Product standard《建筑用玻璃 特种基础产品 玻璃陶瓷 第2-2部分 合格评价 产品标准》.pdf EN 1748-2-2-2004 en Glass in building - Special basic products - Part 2-2 Glass ceramics - Evaluation of conformity Product standard《建筑用玻璃 特种基础产品 玻璃陶瓷 第2-2部分 合格评价 产品标准》.pdf
  • EN 175-1997 en Personal Protection - Equipment for Eye and Face Protection During Welding and Allied Processes《个人防护 焊接和类似加工中眼睛和面部的防护设备》.pdf EN 175-1997 en Personal Protection - Equipment for Eye and Face Protection During Welding and Allied Processes《个人防护 焊接和类似加工中眼睛和面部的防护设备》.pdf
  • EN 1751-2014 en Ventilation for buildings - Air terminal devices - Aerodynamic testing of damper and valves《建筑物的通风 空气终端装置 阻尼器和阀门的气动试验》.pdf EN 1751-2014 en Ventilation for buildings - Air terminal devices - Aerodynamic testing of damper and valves《建筑物的通风 空气终端装置 阻尼器和阀门的气动试验》.pdf
  • 相关搜索

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

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