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

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

1、三级信息管理技术机试-170 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN29.DAT中存有 200个 4位数,并已调用读函数 readDat()把这些数存人数组 a中,请编制一函数 jsVal(),其功能是:把个位数字和千位数字重新组合成一个新的 2位数 ab(新 2位数的十位数字是原 4位数的个位数字,新 2位数的个位数字是原 4位数的千位数字),以及把百位数字和十位数字组成另一个新的 2位数 cd(新 2位数的十位数字是原 4位数的百位数字,新 2位数的个位数字是原 4位数的十位数字),如果新组成的两个数均为偶数

2、且两个 2位数中至少有一个数能被 9整除,同时两个新 2位数的十位数字均不为零,则将满足此条件的 4位数按从大到小的顺序存人数组 b中,并计算满足上述条件的 4位数的个数 cnt,最后调用写函数 writeDat()把结果 cnt及数组 b中符合条件的 4位数输出到 OUT29.DAT文件中。注意:部分源程序已给出。程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序#includestdio.h#define MAX 200int aMAX,bMAX,cnt=0;void writeD

3、at();void jsVal()void readDat()int i;FILE*fp;fp=fopen(“IN29.DAT“,“r“);for(i=0;iMAX;i+)fscanf(fP,“%d“,fclose(fp);void main()int i;readDat();jsVal();printf(“满足条件的数=%d/n“,cnt);for(i=0;icnt;i+)printf(“%d/n“,bi);printf(“/n“);writeDat();void writeDat()FILE*fp;int i;fp=fopen(“OUT29.DAT“,“W“);fprintf(fp,“%d

4、/n“,cnt);for(i=0;icnt;i+)fprintf(fp,“%d/n“,bi);fclose(fp);(分数:100.00)_三级信息管理技术机试-170 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN29.DAT中存有 200个 4位数,并已调用读函数 readDat()把这些数存人数组 a中,请编制一函数 jsVal(),其功能是:把个位数字和千位数字重新组合成一个新的 2位数 ab(新 2位数的十位数字是原 4位数的个位数字,新 2位数的个位数字是原 4位数的千位数字),以及把百位数字和十位数字组成另一

5、个新的 2位数 cd(新 2位数的十位数字是原 4位数的百位数字,新 2位数的个位数字是原 4位数的十位数字),如果新组成的两个数均为偶数且两个 2位数中至少有一个数能被 9整除,同时两个新 2位数的十位数字均不为零,则将满足此条件的 4位数按从大到小的顺序存人数组 b中,并计算满足上述条件的 4位数的个数 cnt,最后调用写函数 writeDat()把结果 cnt及数组 b中符合条件的 4位数输出到 OUT29.DAT文件中。注意:部分源程序已给出。程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()

6、的内容。试题程序#includestdio.h#define MAX 200int aMAX,bMAX,cnt=0;void writeDat();void jsVal()void readDat()int i;FILE*fp;fp=fopen(“IN29.DAT“,“r“);for(i=0;iMAX;i+)fscanf(fP,“%d“,fclose(fp);void main()int i;readDat();jsVal();printf(“满足条件的数=%d/n“,cnt);for(i=0;icnt;i+)printf(“%d/n“,bi);printf(“/n“);writeDat();

7、void writeDat()FILE*fp;int i;fp=fopen(“OUT29.DAT“,“W“);fprintf(fp,“%d/n“,cnt);for(i=0;icnt;i+)fprintf(fp,“%d/n“,bi);fclose(fp);(分数:100.00)_正确答案:(void jsVal()int i,j; /*定义循环控制变量*/int a1,a2,a3,a4; /*定义变量保存 4位数的每位数字*/int temp; /*定义数据交换时的暂存变量*/int ab,cd; /*存储重新组合成的 2位数*/for(i=0;i200;i+) /*逐个取每一个 4位数*/a4

8、ai/1000; /*求 4位数的千位数字*/a3=ai%1000/100; /*求 4位数的百位数字*/a2=ai%100/10; /*求 4位数的十位数字*/a1=ai%10; /*求 4位数的个位数字*/ab=10*a1+a4; /*把个位数字和千位数字重新组合成一个新的 2位数 ab*/cd=10*a3+a2; /*把百位数字和十位数字组成另一个新的 2位数 cd*/if(ab%9=0 |cd%9=0) /*将满足条件的 4位数存入数组 b中*/cnt+; /*统计满足条件的数的个数*/for(i=0;icnt-1;i+) /*将数组 b中的数按从大到小的顺序排列*/for(j=i+

9、1;jcnt;j+)if(bibj)temp=bi;bi=bj;bj=temp;)解析:解析 根据题意可知,函数 jsVal()要实现两个功能:一是找出满足条件的那些数,并将其存放在数组 b中;二是对数组 b中的数进行从大到小的排序。首先要找出满足条件的数,关键在于对新组成的两个 2位数的判断,通过一个 if语句来判断它们是否满足条件“新组成的两个数均为偶数且两个 2位数中至少有一个数能被 9整除,同时两个新 2位数的十位上的数字均不为零”。其次,将满足条件的数存人数组 b中,并用变量 ent来统计数组 b中元素的个数。最后,将所有满足条件的数取出后利用选择法进行排序,即将当前元素依次同它后面的元素进行比较,发现大于该数的数,就将这两数进行交换。

展开阅读全文
相关资源
猜你喜欢
  • GOST 4 406-1985 System of product quality indices Motion-picture films for professional cinematography and television Nomenclature of indices《电影和电视专用胶片 指标项目》.pdf GOST 4 406-1985 System of product quality indices Motion-picture films for professional cinematography and television Nomenclature of indices《电影和电视专用胶片 指标项目》.pdf
  • GOST 4 407-1985 Product-quality index system Sporting hunting and sport-hunting cartridges for rifled fire-arms Index nomenclature《运动、打猎和运动-打猎的来复枪子弹夹 指标项目》.pdf GOST 4 407-1985 Product-quality index system Sporting hunting and sport-hunting cartridges for rifled fire-arms Index nomenclature《运动、打猎和运动-打猎的来复枪子弹夹 指标项目》.pdf
  • GOST 4 409-1985 Product-quality index system Power generating sets and mobile electric power stations with internal combustion engines Index nomenclature《产品质量指标系统 内燃机发电设备及移动电站 指标术语.pdf GOST 4 409-1985 Product-quality index system Power generating sets and mobile electric power stations with internal combustion engines Index nomenclature《产品质量指标系统 内燃机发电设备及移动电站 指标术语.pdf
  • GOST 4 41-1985 Quality rating system Machines for thermal cutting of metals Nomenclature of indices《金属热切割机器 指标名称》.pdf GOST 4 41-1985 Quality rating system Machines for thermal cutting of metals Nomenclature of indices《金属热切割机器 指标名称》.pdf
  • GOST 4 410-1986 Product-quality index system Stable isotope compounds and products Nomenclature of indices《产品质量指标系统 稳定同位素合成物及产品 目录术语》.pdf GOST 4 410-1986 Product-quality index system Stable isotope compounds and products Nomenclature of indices《产品质量指标系统 稳定同位素合成物及产品 目录术语》.pdf
  • GOST 4 411-1986 Index system of production quality Complects of fashion details assambleys and blocks (tube assambleys) for tubes of heat energy stations and atom energy stations wure《.pdf GOST 4 411-1986 Index system of production quality Complects of fashion details assambleys and blocks (tube assambleys) for tubes of heat energy stations and atom energy stations wure《.pdf
  • GOST 4 412-1986 Index system of production quality Butterfly and spherical valves for hydraulic turbines Index nomenclature《CПKП 水轮机用板式及球式阀门 指标名称》.pdf GOST 4 412-1986 Index system of production quality Butterfly and spherical valves for hydraulic turbines Index nomenclature《CПKП 水轮机用板式及球式阀门 指标名称》.pdf
  • GOST 4 413-1986 Index system of production quality Hot water heating boilers Index nomenclature《水暖锅炉 指标项目》.pdf GOST 4 413-1986 Index system of production quality Hot water heating boilers Index nomenclature《水暖锅炉 指标项目》.pdf
  • GOST 4 414-1986 Index system of product quality Coal pulverizing mills Nomenclature of indices《煤块粉碎机 指标项目》.pdf GOST 4 414-1986 Index system of product quality Coal pulverizing mills Nomenclature of indices《煤块粉碎机 指标项目》.pdf
  • 相关搜索

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

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