【计算机类职业资格】三级信息管理技术机试-263及答案解析.doc

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

1、三级信息管理技术机试-263 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.在文件 IN70.DAT 中有 200 组数据,每组有 3 个数,每个数均是 3 位数。函数 readDat()的功能是读取这 200 组数据并存放到结构数组 aa 中。请编制函数 jsSort(),其函数的功能是:要求在 200 组数据中找出条件为每组数据中的第二个数大于第一个数加第三个数之和,其中满足条件的个数作为函数 jsSort()的返回值,同时把满足条件的数据存入结构数组 bb 中,再对结构数组 bb 中的数据按照每组数据的第二个数加第三个数之和的大小进

2、行降序排列,排序后的结果仍重新存入结构数组 bb 中,最后调用函数writeDat()把结果 bb 输出到文件 OUT70.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序:#include stdio.h#include string.h#include stdlib.htypedef structint x1,x2,x3;Data;Data aa200,bb200;void readDat();void writeDat();int jsSort()void main()int count;readD

3、at();count=jsSort();/*返回满足条件的个数*/writeDat(count);void readDat()FILE * in;int i;in=fopen(“IN70.DAT“,“r“);for(i=0;i200;i + +)fscanf(in,“% d % d % d“,&aai.x1,&aai.x2,&aai.x3);fclose(in);void writeDat(int count)FILE * out;int i;out=fopen(“OUT70.DAT“,“w“);system(“CLS“);for(i=0;icount;i + +)printf(“% d,%

4、d,% d 第二个数+第三个数=% d/n“,bbi.x1,bbi.x2,bbi.x3,bbi.x2+bbi.x3);fprintf(out,“% d,% 5d,% d/n“,bbi.x1,bbi.x2,bbi.x3);fclose(out);(分数:100.00)_三级信息管理技术机试-263 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.在文件 IN70.DAT 中有 200 组数据,每组有 3 个数,每个数均是 3 位数。函数 readDat()的功能是读取这 200 组数据并存放到结构数组 aa 中。请编制函数 jsSort(),其

5、函数的功能是:要求在 200 组数据中找出条件为每组数据中的第二个数大于第一个数加第三个数之和,其中满足条件的个数作为函数 jsSort()的返回值,同时把满足条件的数据存入结构数组 bb 中,再对结构数组 bb 中的数据按照每组数据的第二个数加第三个数之和的大小进行降序排列,排序后的结果仍重新存入结构数组 bb 中,最后调用函数writeDat()把结果 bb 输出到文件 OUT70.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序:#include stdio.h#include string.h#i

6、nclude stdlib.htypedef structint x1,x2,x3;Data;Data aa200,bb200;void readDat();void writeDat();int jsSort()void main()int count;readDat();count=jsSort();/*返回满足条件的个数*/writeDat(count);void readDat()FILE * in;int i;in=fopen(“IN70.DAT“,“r“);for(i=0;i200;i + +)fscanf(in,“% d % d % d“,&aai.x1,&aai.x2,&aai

7、x3);fclose(in);void writeDat(int count)FILE * out;int i;out=fopen(“OUT70.DAT“,“w“);system(“CLS“);for(i=0;icount;i + +)printf(“% d,% d,% d 第二个数+第三个数=% d/n“,bbi.x1,bbi.x2,bbi.x3,bbi.x2+bbi.x3);fprintf(out,“% d,% 5d,% d/n“,bbi.x1,bbi.x2,bbi.x3);fclose(out);(分数:100.00)_正确答案:(int jsSort()int i,j; /*定义循环

8、控制变量*/int cnt=0; /*定义计数器变量*/Data temp; /*定义数据交换时的暂存变量,这里是一个 Data 类型的结构体变量*/for(i=0;i200;i + +)if(aai.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.x3temp=bbi;bbi=bbj;bbj=temp;teturn cnt; /*返回满足条件的数据的组数*/)解析:解析 本题考查对结构体数组中元素的各个成员的操作。首先利用一个 for 循环来依次取得结构体数组中的各个元素,然后按照题目要求对当前元素的各个域进行条件判断,如果条件(第二个数大于第一个数加第三个数之和)成立,则将其存放到数组 bb 中。再按照“每组数据中的第二个数加第三个数之和的大小”进行从大到小的排序。

展开阅读全文
相关资源
猜你喜欢
  • ASTM D4741-2017 Standard Test Method for Measuring Viscosity at High Temperature and High Shear Rate by Tapered-Plug Viscometer《高温和高剪切速率下用锥塞粘度计测量粘度的标准试验方法》.pdf ASTM D4741-2017 Standard Test Method for Measuring Viscosity at High Temperature and High Shear Rate by Tapered-Plug Viscometer《高温和高剪切速率下用锥塞粘度计测量粘度的标准试验方法》.pdf
  • ASTM D4741-2018 Standard Test Method for Measuring Viscosity at High Temperature and High Shear Rate by Tapered-Plug Viscometer.pdf ASTM D4741-2018 Standard Test Method for Measuring Viscosity at High Temperature and High Shear Rate by Tapered-Plug Viscometer.pdf
  • ASTM D4742-2002a Standard Test Method for Oxidation Stability of Gasoline Automotive Engine Oils by Thin-Film Oxygen Uptake (TFOUT)《用薄膜氧吸收法测定汽油汽车发动机油氧化稳定性的标准试验方法》.pdf ASTM D4742-2002a Standard Test Method for Oxidation Stability of Gasoline Automotive Engine Oils by Thin-Film Oxygen Uptake (TFOUT)《用薄膜氧吸收法测定汽油汽车发动机油氧化稳定性的标准试验方法》.pdf
  • ASTM D4742-2008 Standard Test Method for Oxidation Stability of Gasoline Automotive Engine Oils by Thin-Film Oxygen Uptake (TFOUT).pdf ASTM D4742-2008 Standard Test Method for Oxidation Stability of Gasoline Automotive Engine Oils by Thin-Film Oxygen Uptake (TFOUT).pdf
  • ASTM D4742-2008e1 Standard Test Method for Oxidation Stability of Gasoline Automotive Engine Oils by Thin-Film Oxygen Uptake (TFOUT)《用氧化薄膜吸收法对汽车发动机油氧化稳定性的标准试验方法》.pdf ASTM D4742-2008e1 Standard Test Method for Oxidation Stability of Gasoline Automotive Engine Oils by Thin-Film Oxygen Uptake (TFOUT)《用氧化薄膜吸收法对汽车发动机油氧化稳定性的标准试验方法》.pdf
  • ASTM D4742-2016 Standard Test Method for Oxidation Stability of Gasoline Automotive Engine Oils by Thin-Film Oxygen Uptake (TFOUT)《采用薄膜吸氧法 (TFOUT) 测定汽油汽车发动机机油的氧化稳定性的标准试验方法》.pdf ASTM D4742-2016 Standard Test Method for Oxidation Stability of Gasoline Automotive Engine Oils by Thin-Film Oxygen Uptake (TFOUT)《采用薄膜吸氧法 (TFOUT) 测定汽油汽车发动机机油的氧化稳定性的标准试验方法》.pdf
  • ASTM D4742-2017 Standard Test Method for Oxidation Stability of Gasoline Automotive Engine Oils by Thin-Film Oxygen Uptake (TFOUT)《利用薄膜耗氧量(TFOUT)测定车用汽油发动机油氧化稳定性的标准试验方法》.pdf ASTM D4742-2017 Standard Test Method for Oxidation Stability of Gasoline Automotive Engine Oils by Thin-Film Oxygen Uptake (TFOUT)《利用薄膜耗氧量(TFOUT)测定车用汽油发动机油氧化稳定性的标准试验方法》.pdf
  • ASTM D4745-2006 Standard Specification for Filled Compounds of Polytetrafluoroethylene (PTFE) Molding and Extrusion Materials《聚四氟乙烯(PTFE)模塑和挤压材料的填充化合物标准规范》.pdf ASTM D4745-2006 Standard Specification for Filled Compounds of Polytetrafluoroethylene (PTFE) Molding and Extrusion Materials《聚四氟乙烯(PTFE)模塑和挤压材料的填充化合物标准规范》.pdf
  • ASTM D4745-2008 Standard Specification for Filled Compounds of Polytetrafluoroethylene (PTFE) Molding and Extrusion Materials《聚四氟乙烯模压和挤压料填充化合物的标准规范》.pdf ASTM D4745-2008 Standard Specification for Filled Compounds of Polytetrafluoroethylene (PTFE) Molding and Extrusion Materials《聚四氟乙烯模压和挤压料填充化合物的标准规范》.pdf
  • 相关搜索

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

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