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

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

1、计算机三级数据库技术-91 及答案解析(总分:100.00,做题时间:90 分钟)1.在文件 IN.DAT 中有 200 组数据,每组有 3 个数,每个数均是 3 位数。函数 readDat()的功能是读取这200 组数据,存放到结构数组 aa 中。请编写函数 jsSort(),返回满足此条件的数的个数。其函数的功能是:在 200 组数据中找出满足每组数据中的第二个数大于第一个数加第三个数之和这个条件的数,并把这些数存入结构数组 bb 中,再对结构数组 bb 中的数据按照每组数据的第二个数加第三个数之和的大小顺序进行降序排列,排序后的结果仍重新存入结构数组 bb 中。最后调用函数 writeD

2、at(),把结果 bb 输出到文件 OUT.DAT 中。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序 #includestdio.h #includestring.h #includestdlib.h typedef struct int x1, x2, x3; Data; Data aa200, bb200; void readDat(); void writeDat(); int jsSort() /返回满足条件的数的个数 void main() int count; readDat(); count=jsSort(); wri

3、teDat(count); void readDat() FILE*in; int i; in=fopen(“IN.DAT“, “r“); for(i=0; i200; i+) fscanf(in, “%d%d%d“, fclose(in); void writeDat(int count) FILE*out; int i; out=fopen(“OUT.DAT“, “w“); system(“CLS“); for(i=0; icount; i+) printf(“%d, %d, %d 第二个数+第三个数=%dn“, bbi.x1, bbi.x2, bbi.x3, bbi.x2+bbi.x3)

4、 fprintf(out, “%d, %d, %dn“, bbi.x1, bbi.x2, bbi.x3); fclose(out); (分数:100.00)_计算机三级数据库技术-91 答案解析(总分:100.00,做题时间:90 分钟)1.在文件 IN.DAT 中有 200 组数据,每组有 3 个数,每个数均是 3 位数。函数 readDat()的功能是读取这200 组数据,存放到结构数组 aa 中。请编写函数 jsSort(),返回满足此条件的数的个数。其函数的功能是:在 200 组数据中找出满足每组数据中的第二个数大于第一个数加第三个数之和这个条件的数,并把这些数存入结构数组 bb 中

5、再对结构数组 bb 中的数据按照每组数据的第二个数加第三个数之和的大小顺序进行降序排列,排序后的结果仍重新存入结构数组 bb 中。最后调用函数 writeDat(),把结果 bb 输出到文件 OUT.DAT 中。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序 #includestdio.h #includestring.h #includestdlib.h typedef struct int x1, x2, x3; Data; Data aa200, bb200; void readDat(); void writeDat();

6、int jsSort() /返回满足条件的数的个数 void main() int count; readDat(); count=jsSort(); writeDat(count); void readDat() FILE*in; int i; in=fopen(“IN.DAT“, “r“); for(i=0; i200; i+) fscanf(in, “%d%d%d“, fclose(in); void writeDat(int count) FILE*out; int i; out=fopen(“OUT.DAT“, “w“); system(“CLS“); for(i=0; icount

7、 i+) printf(“%d, %d, %d 第二个数+第三个数=%dn“, bbi.x1, bbi.x2, bbi.x3, bbi.x2+bbi.x3); fprintf(out, “%d, %d, %dn“, bbi.x1, bbi.x2, bbi.x3); fclose(out); (分数:100.00)_正确答案:()解析:int jsSort() int i, j; /*定义循环控制变量*/ int cnt=0; /*定义计数器变量*/ Data temp; /*定义数据交换时的暂存变量,这里是一个 Data 类型的结构体变量*/ for(i=0; i200; i+) if(aa

8、i.x2aai.x1+aai.x3) /*如果第二个数大于第一个数加第三个数之和*/ bbcnt=aai; /*则把该组数据存入结构数组 bb 中*/ cnt+; /*同时统计满足条件的数据的个数*/ for(i=0; icnt-1; i+) /*对结构数组 bb 中的数据按照每组数据的第二个数加第三个数之和的大小进行降序排列*/ for(j=i+1; jcnt; j+) if(bbi.x2+bbi.x3bbj.x2+bbj.x3) temp=bbi; bbi=bbj; bbj=temp; return cnt; /*返回满足条件数据的组数*/ 考点 本题考查的知识点主要包括:结构体成员的访问,元素的排序,if 判断结构和逻辑表达式。 此题属于结构体的筛选排序问题。分析题干要求,可以归纳出 3 个关键点:关键点 1 通过条件“每组数据中第 2 个数大于第 1 个数和第 3 个数之和”对每组数据进行判断;关键点 2 保存满足条件的数到新数组中并统计其数量;关键点 3 对新数组中的数再按照第 2 个数和第 3 个数之和的大小进行降序排列;关键点 4函数的返回值为之前统计的满足的数据的组数。 接着分析具体的解决方法,首先通过 if 判断结构和逻辑表达式实现对所有结构的筛选,保存并统计个数,然后通过起泡法完成排序,最后函数返回组数。

展开阅读全文
相关资源
猜你喜欢
  • GOST R 41 96-2011 Uniform provisions concerning the approval of compression ignition engines to be installed in agricultural and forestry tractors and in non-road mobile machinery e en.pdf GOST R 41 96-2011 Uniform provisions concerning the approval of compression ignition engines to be installed in agricultural and forestry tractors and in non-road mobile machinery e en.pdf
  • GOST R 41 97-1999 Uniform provisions concerning the approval of vehicle alarm system (VAS) and of motor vehicles with regard to their alarm system (AS)《关于审核车辆警报系统(VAS)和机动车辆警报系统(AS).pdf GOST R 41 97-1999 Uniform provisions concerning the approval of vehicle alarm system (VAS) and of motor vehicles with regard to their alarm system (AS)《关于审核车辆警报系统(VAS)和机动车辆警报系统(AS).pdf
  • GOST R 41 98-1999 Uniform provisions concerning the approval of motor vehicles headlamps equipped with gas-discharge light sources《关于审核机动车辆前照灯(配有气体放电光源)的统一规定》.pdf GOST R 41 98-1999 Uniform provisions concerning the approval of motor vehicles headlamps equipped with gas-discharge light sources《关于审核机动车辆前照灯(配有气体放电光源)的统一规定》.pdf
  • GOST R 41 99-1999 Uniform provisions concerning the approval of gas-discharge light sources for use in approved gas-discharge lamp units of power-driven vehicles《关于审核用于机动车辆批准采用的气体放.pdf GOST R 41 99-1999 Uniform provisions concerning the approval of gas-discharge light sources for use in approved gas-discharge lamp units of power-driven vehicles《关于审核用于机动车辆批准采用的气体放.pdf
  • GOST R 42 0 01-2000 Civil defence Basic principles《民防 基本原则》.pdf GOST R 42 0 01-2000 Civil defence Basic principles《民防 基本原则》.pdf
  • GOST R 42 0 02-2001 Civil defence Basic terms and definitions《民防 基本术语和定义》.pdf GOST R 42 0 02-2001 Civil defence Basic terms and definitions《民防 基本术语和定义》.pdf
  • GOST R 42 2 01-2014 Civil Defence Assessment of the state of hazardous facilities defence and security facilities exposed to the damaging factors of conventional weapons Calculatio.pdf GOST R 42 2 01-2014 Civil Defence Assessment of the state of hazardous facilities defence and security facilities exposed to the damaging factors of conventional weapons Calculatio.pdf
  • GOST R 42 3 01-2014 Civil defense Technical means of public notification Classification General technical requirements《民防 公共通知的技术手段 分类 通用技术要求》.pdf GOST R 42 3 01-2014 Civil defense Technical means of public notification Classification General technical requirements《民防 公共通知的技术手段 分类 通用技术要求》.pdf
  • GOST R 42 3 02-2014 Civil defense Technical means of communication and control Classification General technical requirements《民防 通信和控制的技术手段 分类 通用技术要求》.pdf GOST R 42 3 02-2014 Civil defense Technical means of communication and control Classification General technical requirements《民防 通信和控制的技术手段 分类 通用技术要求》.pdf
  • 相关搜索

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

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