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

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

1、三级数据库技术机试-208 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.在文件 IN.dat中有 200组数据,每组有 3个数,每个数均是三位数。函数 Rdata()读取这 200 组数据存放到结构数组 aa中,请编写函数 greatSort(),其功能是:要求在 200组数据中找出条件为每组中的第 1个数大于第 2个数加第 3个数的和,其中满足条件的组数作为函数 greatSort()的返回值,同时把满足条件的数据存入结构数组 bb中,再对 bb中的数据按照每组数据的第 1个数加第 3个数之和的大小进行升序排列(第 1个数加第 3个数

2、的和均不相等),排序后的结果仍重新存入结构数组 bb中。最后调用函数Wdata(),把结果 bb输出到 OUT.dat文件中。注意:部分源程序已经给出。请勿改动主函数 main()、读数据函数 Rdata()和输出数据函数 Wdata()的内容。#include stdio. h#include string.h#include conio. htypedef structint x1, x2, x3;data;data aa200, bb200;int greatSort ()void Rdata ()FILE *in;int i;in = fopen(“IN.dat“, “r“);for

3、i=0; i200; i+)fscanf (in, “%d %d %d“, fclose (in);void Wdata(int count)FILE *out;int i;out = fopen(“OUT.dat“, “w“);for (i=0; icount; i+)printf(“%d,%d,%d 第一个数+第三个数=%d/n“, bbi.x1,bbi.x2, bbi.x3, bbi.x1 + bbi. x3);fprintf (out, “%d %d %d/n“, bbi .x1, bbi .x2,bbi .x3);fclose (out);void main () int coun

4、t;Rdata ( );count = greatSort() ;/* 返回满足条件的个数 */Wdata (count); (分数:100.00)_三级数据库技术机试-208 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.在文件 IN.dat中有 200组数据,每组有 3个数,每个数均是三位数。函数 Rdata()读取这 200 组数据存放到结构数组 aa中,请编写函数 greatSort(),其功能是:要求在 200组数据中找出条件为每组中的第 1个数大于第 2个数加第 3个数的和,其中满足条件的组数作为函数 greatSort()的返

5、回值,同时把满足条件的数据存入结构数组 bb中,再对 bb中的数据按照每组数据的第 1个数加第 3个数之和的大小进行升序排列(第 1个数加第 3个数的和均不相等),排序后的结果仍重新存入结构数组 bb中。最后调用函数Wdata(),把结果 bb输出到 OUT.dat文件中。注意:部分源程序已经给出。请勿改动主函数 main()、读数据函数 Rdata()和输出数据函数 Wdata()的内容。#include stdio. h#include string.h#include conio. htypedef structint x1, x2, x3;data;data aa200, bb200;

6、int greatSort ()void Rdata ()FILE *in;int i;in = fopen(“IN.dat“, “r“);for (i=0; i200; i+)fscanf (in, “%d %d %d“, fclose (in);void Wdata(int count)FILE *out;int i;out = fopen(“OUT.dat“, “w“);for (i=0; icount; i+)printf(“%d,%d,%d 第一个数+第三个数=%d/n“, bbi.x1,bbi.x2, bbi.x3, bbi.x1 + bbi. x3);fprintf (out,

7、d %d %d/n“, bbi .x1, bbi .x2,bbi .x3);fclose (out);void main () int count;Rdata ( );count = greatSort() ;/* 返回满足条件的个数 */Wdata (count); (分数:100.00)_正确答案:(int greatSort() int i, j, count = 0;data val;for (i=0; i200; i+)if (aai .x1 aai .x2+aai .x3) bbcount = aai;count+;for (i=0; icount-1; i+)for (j=i+1; jcount; j+)if (bbi .x1+bbi .x3 bbj .x1+bbj .x3) va1 = bbi;bbi = bbj;bbj = va1;return count;)解析:解题思路 在 for循环语句中,自变量 i从 0递增到 200,判断每组中的第 1个数大于第 2个数加第 3个数之和即表达式 aai. x1aai. x2+aai. x3 是否成立,如果表达式成立,即把 aa i 赋给数组变量 bb,同时计数变量 count自加。最后用两重循环对数组 bb中的数据按照每组数据的第 2个数加第 3个数之和的大小进行升序排列。

展开阅读全文
相关资源
猜你喜欢
  • NF A70-011-1993 Colours of gold alloys Definition range of colours and designation 《金合金的颜色 定义、颜色范围和标识》.pdf NF A70-011-1993 Colours of gold alloys Definition range of colours and designation 《金合金的颜色 定义、颜色范围和标识》.pdf
  • NF A72-115-1966 Blast furnace accessories Hot air valves Discs and seats PN 6 《高炉附件 热风阀 阀盖和底座(PN6)》.pdf NF A72-115-1966 Blast furnace accessories Hot air valves Discs and seats PN 6 《高炉附件 热风阀 阀盖和底座(PN6)》.pdf
  • NF A72-120-1973 Large diameter pipes and valves for gaseous fluids Flange connections PN 6 《气态液体用大直径管道和阀 带法兰的接头(PN6)》.pdf NF A72-120-1973 Large diameter pipes and valves for gaseous fluids Flange connections PN 6 《气态液体用大直径管道和阀 带法兰的接头(PN6)》.pdf
  • NF A80-004-2005 Welding and allied processes - Definitions of metal welding processes 《焊接和相关工艺 金属焊接工艺的定义》.pdf NF A80-004-2005 Welding and allied processes - Definitions of metal welding processes 《焊接和相关工艺 金属焊接工艺的定义》.pdf
  • NF A80-230-1-2007 Welding and allied processes - Classification of geometric imperfections in metallic materials - Part 1  fusion welding 《焊接和相关工艺 金属材料几何缺陷的分类 第1部分 氧炔焊》.pdf NF A80-230-1-2007 Welding and allied processes - Classification of geometric imperfections in metallic materials - Part 1 fusion welding 《焊接和相关工艺 金属材料几何缺陷的分类 第1部分 氧炔焊》.pdf
  • NF A81-303-2003 Covered electrodes for manual metal arc welding - Procedure for the deposition of weld metal - Hardness tests 《手工电弧焊用涂剂焊条 焊接金属沉积方法 硬度试验》.pdf NF A81-303-2003 Covered electrodes for manual metal arc welding - Procedure for the deposition of weld metal - Hardness tests 《手工电弧焊用涂剂焊条 焊接金属沉积方法 硬度试验》.pdf
  • NF A81-306-1994 Covered electrodes Determination of the efficiency metal recovery and deposition coefficient 《药皮焊条 效率、金属回复系数和熔敷系数的测定》.pdf NF A81-306-1994 Covered electrodes Determination of the efficiency metal recovery and deposition coefficient 《药皮焊条 效率、金属回复系数和熔敷系数的测定》.pdf
  • NF A81-308-1989 Covered electrodes for manual arc welding Measuring of the complete coating moisture Test method 《手工电弧焊用药皮焊条 药皮水总含量的测定方法》.pdf NF A81-308-1989 Covered electrodes for manual arc welding Measuring of the complete coating moisture Test method 《手工电弧焊用药皮焊条 药皮水总含量的测定方法》.pdf
  • NF A81-314-1990 Welding Solid bare wires and rods depositing a stainless and or heat resisting steel weld metal Tests on weld metal 《焊接 存放不锈钢和 或耐热钢的焊接金属的固体裸露线材和棒材 焊缝金属试验 》.pdf NF A81-314-1990 Welding Solid bare wires and rods depositing a stainless and or heat resisting steel weld metal Tests on weld metal 《焊接 存放不锈钢和 或耐热钢的焊接金属的固体裸露线材和棒材 焊缝金属试验 》.pdf
  • 相关搜索

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

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