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

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

1、三级数据库技术-514 及答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.在数据文件 in.dat中有 200组数据,每组有 3个数,每个数均是三位数。函数 readDat()是读取这 200组数据存放到结构数组 aa中。请编制函数 isSort(),其函数的功能是:要求在 200组数据中找出第一个数大于第二个数与第三个数之和的数,其中满足条件的个数作为函数 jsSort()的返回值,同时把满足条件的数据存入结构数组 bb中,再对 bb中的数据按照每组数据的第一个数与第三个数之和的大小进行升序排列(第一个数与第三个数的和均不相等),排序

2、后的结果仍重新存入结构数组 bb中,最后调用函数writeDat()把结果 bb输出到 out.dat文件中。 请勿改动数据文件 in.dat中的任何数据、主函数 main()、读函数 readDat()和写函数 writeDat()的内容。#include stdio.h #include string.h void readDat(); void writeDat(int count); typedef struct int x1, x2, x3; Data; Data aa200, bb200; int jsSort () void main() int count; readDat (

3、); count=jsSort(); writeDat (count); / *读取这 200组数据存放到结构数组 aa中“/ void readDat() FILE *in; int i; in=fopen(“in.dat“, “r“); for(i=0; i200; i+) fscanf(in, “%d,%d,%d“, fclose (in); /*把结果 bb输出到 out.dat文件中*/ void writeDat(int count) FILE *out; int i; out=fopen(“out.dat“, “w“); for(i=0; icount; i+) printf(“

4、d,%d,%d第一个数+第三个数=%dn“, bbi.x1, bbi.x2, bbi.x3, bbi.x1+bbi.x3); fprintf(out, “%d,%d,%dn“, bbi.x1, bbi .x2, bbi.x3); fclose(out); (分数:100.00)_三级数据库技术-514 答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.在数据文件 in.dat中有 200组数据,每组有 3个数,每个数均是三位数。函数 readDat()是读取这 200组数据存放到结构数组 aa中。请编制函数 isSort(),其函数的功

5、能是:要求在 200组数据中找出第一个数大于第二个数与第三个数之和的数,其中满足条件的个数作为函数 jsSort()的返回值,同时把满足条件的数据存入结构数组 bb中,再对 bb中的数据按照每组数据的第一个数与第三个数之和的大小进行升序排列(第一个数与第三个数的和均不相等),排序后的结果仍重新存入结构数组 bb中,最后调用函数writeDat()把结果 bb输出到 out.dat文件中。 请勿改动数据文件 in.dat中的任何数据、主函数 main()、读函数 readDat()和写函数 writeDat()的内容。#include stdio.h #include string.h void

6、 readDat(); void writeDat(int count); typedef struct int x1, x2, x3; Data; Data aa200, bb200; int jsSort () void main() int count; readDat (); count=jsSort(); writeDat (count); / *读取这 200组数据存放到结构数组 aa中“/ void readDat() FILE *in; int i; in=fopen(“in.dat“, “r“); for(i=0; i200; i+) fscanf(in, “%d,%d,%d

7、 fclose (in); /*把结果 bb输出到 out.dat文件中*/ void writeDat(int count) FILE *out; int i; out=fopen(“out.dat“, “w“); for(i=0; icount; i+) printf(“%d,%d,%d第一个数+第三个数=%dn“, bbi.x1, bbi.x2, bbi.x3, bbi.x1+bbi.x3); fprintf(out, “%d,%d,%dn“, bbi.x1, bbi .x2, bbi.x3); fclose(out); (分数:100.00)_正确答案:()解析:int i,j,c

8、ount=0; Data cc; for(i=0; i200; i+) /*如果 aai的第一个数大于第二个数加第三个数之和,则把 aai复制到 bbcount中,同时数组下标变量 count;加 1*/ if(aai.x1 (aai.x2+aai.x3) memcpy(Data*) /*对 bb中的数据按照每组数据的第一个数与第三个数之和的大小进行升序排列*/ for(i=0; i(count-1); i+) for(j=2+1; jcount;j+) /*如果 bbi的第一个数与第三个数之和大于 bbj的第一个数与第三个数之和,则 bbi与 bbj互换*/ if(bbi.x1+bbi.x3)(bbj.x1+bbj.x3) memcpy(Data*) memcpy(Data*) memcpy(Data*) return count; /返回满足条件的数据的个数 解析 第 1个数大于第 2个数加第 3个数,存入数组,按第 1个加第 3个数之和升序排序。 通过审题可以发现主要有两个不同点:筛选满足条件的记录不同,参考答案的第 5行,修改 if条件语句的设置即可;对满足条件的筛选结果进行排序的条件不同,参考答案的 11行,修改 if条件语句的设置即可。

展开阅读全文
相关资源
猜你喜欢
  • ASTM A768 A768M-2005 Standard Specification for Vacuum-Treated 12 % Chromium Alloy Steel Forgings for Turbine Rotors and Shafts.pdf ASTM A768 A768M-2005 Standard Specification for Vacuum-Treated 12 % Chromium Alloy Steel Forgings for Turbine Rotors and Shafts.pdf
  • ASTM A768 A768M-2005(2010) Standard Specification for Vacuum-Treated 12 % Chromium Alloy Steel Forgings for Turbine Rotors and Shafts《涡轮机转子及轴用真空处理的含12%铬合金钢锻件用标准规范》.pdf ASTM A768 A768M-2005(2010) Standard Specification for Vacuum-Treated 12 % Chromium Alloy Steel Forgings for Turbine Rotors and Shafts《涡轮机转子及轴用真空处理的含12%铬合金钢锻件用标准规范》.pdf
  • ASTM A769 A769M-2005 Standard Specification for Carbon and High-Strength Electric Resistance Forge-Welded Steel Structural Shapes.pdf ASTM A769 A769M-2005 Standard Specification for Carbon and High-Strength Electric Resistance Forge-Welded Steel Structural Shapes.pdf
  • ASTM A769 A769M-2005(2010) Standard Specification for Carbon and High-Strength Electric Resistance Forge-Welded Steel Structural Shapes《碳素和高强度电阻焊钢结构型材的标准规范》.pdf ASTM A769 A769M-2005(2010) Standard Specification for Carbon and High-Strength Electric Resistance Forge-Welded Steel Structural Shapes《碳素和高强度电阻焊钢结构型材的标准规范》.pdf
  • ASTM A769 A769M-2017 Standard Specification for Carbon and High-Strength Electric Resistance Forge-Welded Steel Structural Shapes《碳素和高强度电阻锻焊式钢结构形状的标准规格》.pdf ASTM A769 A769M-2017 Standard Specification for Carbon and High-Strength Electric Resistance Forge-Welded Steel Structural Shapes《碳素和高强度电阻锻焊式钢结构形状的标准规格》.pdf
  • ASTM A770 A770M-2003 Standard Specification for Through-Thickness Tension Testing of Steel Plates for Special Applications.pdf ASTM A770 A770M-2003 Standard Specification for Through-Thickness Tension Testing of Steel Plates for Special Applications.pdf
  • ASTM A770 A770M-2003(2007) Standard Specification for Through-Thickness Tension Testing of Steel Plates for Special Applications《专用钢板通过厚度测量进行的抗拉试验》.pdf ASTM A770 A770M-2003(2007) Standard Specification for Through-Thickness Tension Testing of Steel Plates for Special Applications《专用钢板通过厚度测量进行的抗拉试验》.pdf
  • ASTM A770 A770M-2003(2012) Standard Specification for Through-Thickness Tension Testing of Steel Plates for Special Applications《专用钢板通过厚度测量进行的抗拉试验》.pdf ASTM A770 A770M-2003(2012) Standard Specification for Through-Thickness Tension Testing of Steel Plates for Special Applications《专用钢板通过厚度测量进行的抗拉试验》.pdf
  • ASTM A770 A770M-2003(2012)e1 Standard Specification for Through-Thickness Tension Testing of Steel Plates for Special Applications《专用钢板通过厚度测量进行的抗拉试验的标准规格》.pdf ASTM A770 A770M-2003(2012)e1 Standard Specification for Through-Thickness Tension Testing of Steel Plates for Special Applications《专用钢板通过厚度测量进行的抗拉试验的标准规格》.pdf
  • 相关搜索

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

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