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

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

1、三级信息管理技术机试-291 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN38.DAT 中存有 200 个 4 位数,并已调用读函数 readDat()把这些数存人数组 a 中。请编制函数 jsVal(),其功能是:依次从数组 a 中取出一个 4 位数,如果 4 位数连续大于该 4 位数以前的 5个数且该数是奇数(该 4 位数以前不满 5 个数,则不统计),该数必须能被 7 整除,则统计出满足此条件的数的个数 cnt,并把这些 4 位数按从大到小的顺序存人数组 b 中,最后调用写函数 wfiteDat()把结果 cnt

2、及数组 b 中符合条件的 4 位数输出到 OUT38.DAT 文件中。注意:部分源程序已给出。程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序#includestdio.h#define MAX 200int aMAX,bMAX,cnt=0;void writeDat();void jsVal()void readDat()int i;FILE*fp;fp=fopen(“IN38.DAT“,“r“);for(i=0;iMAX;i+)fscanf(fp,“%d“,fclose(fp);

3、voidmain()int i;readDat();jsVal();printf(“满足条件的数=%d/n“,cnt);for(i=0;icnt;i+)printf(“%d“,bi);printf(“/n“);writeDat();void writeDat()FILE*fP;int i;fp=fopen(“OUT38.DAT“,“W“);fprintf(fp,“%d/n“,cnt);for(i=0;icnt;i+)fprintf(fp,“%d/n“,bi);fclose(fp);(分数:100.00)_三级信息管理技术机试-291 答案解析(总分:100.00,做题时间:90 分钟)一、上机

4、题(总题数:1,分数:100.00)1.已知数据文件 IN38.DAT 中存有 200 个 4 位数,并已调用读函数 readDat()把这些数存人数组 a 中。请编制函数 jsVal(),其功能是:依次从数组 a 中取出一个 4 位数,如果 4 位数连续大于该 4 位数以前的 5个数且该数是奇数(该 4 位数以前不满 5 个数,则不统计),该数必须能被 7 整除,则统计出满足此条件的数的个数 cnt,并把这些 4 位数按从大到小的顺序存人数组 b 中,最后调用写函数 wfiteDat()把结果 cnt及数组 b 中符合条件的 4 位数输出到 OUT38.DAT 文件中。注意:部分源程序已给出

5、程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序#includestdio.h#define MAX 200int aMAX,bMAX,cnt=0;void writeDat();void jsVal()void readDat()int i;FILE*fp;fp=fopen(“IN38.DAT“,“r“);for(i=0;iMAX;i+)fscanf(fp,“%d“,fclose(fp);voidmain()int i;readDat();jsVal();printf(“满足条件

6、的数=%d/n“,cnt);for(i=0;icnt;i+)printf(“%d“,bi);printf(“/n“);writeDat();void writeDat()FILE*fP;int i;fp=fopen(“OUT38.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 temp; /*定义数据交换时的暂存变量*/for(i=5;iMAX;i+) /*逐个取每个 4

7、 位数*/if(ai%2!=0j=i-1;j+) /*取该数前面的 5 个数进行比较*/if(aiaj)break; /*如果当前数不满足比前面 5 个数都大的条件,则跳出循环*/if(j=i) /*如果当前数比前面的 5 个数都大*/bcnt=ai; /*将满足条件的数存入数组 b 中*/cnt+; /*并统计满足条件的数的个数*/for(i=0;icnt-1;i+) /*利用选择法对数组 b 中的元素进行从大到小的排序*/for(j=i+1;jcnt;j+)if(bibj)temp=bi;bi=bj;bj=temp;)解析:解析 根据题意可知,要编制函数的功能有两部分:一是找出满足条件的 4 位数,二是对找出的数进行从大到小的排序。首先利用一个 for 循环来依次从数组中取得 4 位数,用一个 if 语句依次判断每个数是否为奇数并且能否被 7 整除。接着再通过一个 for 循环将是奇数且可被 7 整除的 4 位数与该数后面的 5 个数依次进行比较,如果该数比前面的 5 个数都大,则把该数加入到数组 b 中,并用变量 cnt 来统计出满足条件的 4 位数的个数。最后利用选择法对数组 b 中的元素进行从大到小的排序。

展开阅读全文
相关资源
猜你喜欢
  • BS ISO 9459-4-2013 Solar heating Domestic water heating systems System performance characterization by means of component tests and computer simulation《太阳能加热 家用热水系统 利用组合测验和计算机模拟的系统.pdf BS ISO 9459-4-2013 Solar heating Domestic water heating systems System performance characterization by means of component tests and computer simulation《太阳能加热 家用热水系统 利用组合测验和计算机模拟的系统.pdf
  • BS ISO 9459-5-2007 Solar heating Domestic water heating systems System performance characterization by means of whole-system tests and computer simulation《太阳能加热 家用热水系统 依赖于全系统试验和计算机.pdf BS ISO 9459-5-2007 Solar heating Domestic water heating systems System performance characterization by means of whole-system tests and computer simulation《太阳能加热 家用热水系统 依赖于全系统试验和计算机.pdf
  • BS ISO 9564-2-2014 Financial services Personal Identification Number (PIN) management and security Approved algorithms for PIN encipherment《金融服务 个人识别号码 (PIN) 管理和安全 核准的PIN密码算法》.pdf BS ISO 9564-2-2014 Financial services Personal Identification Number (PIN) management and security Approved algorithms for PIN encipherment《金融服务 个人识别号码 (PIN) 管理和安全 核准的PIN密码算法》.pdf
  • BS ISO 9564-4-2016 Financial services Personal Identification Number (PIN) management and security Requirements for PIN handling in eCommerce for Payment Transactions《金融服务 个人识别号码 (.pdf BS ISO 9564-4-2016 Financial services Personal Identification Number (PIN) management and security Requirements for PIN handling in eCommerce for Payment Transactions《金融服务 个人识别号码 (.pdf
  • BS ISO 9599-2015 Copper lead zinc and nickel sulfide concentrates Determination of hygroscopic moisture content of the analysis sample Gravimetric method《铜 铅 锌和硫化镍精矿 分析样本中湿存水分含量的测定.pdf BS ISO 9599-2015 Copper lead zinc and nickel sulfide concentrates Determination of hygroscopic moisture content of the analysis sample Gravimetric method《铜 铅 锌和硫化镍精矿 分析样本中湿存水分含量的测定.pdf
  • BS ISO 96-1-2016 Textile machinery and accessories Rings and travellers for ring spinning and ring twisting frames Flange rings T and SF and their travellers《纺织机械和附件 环锭细纱机和环锭捻线机用钢领.pdf BS ISO 96-1-2016 Textile machinery and accessories Rings and travellers for ring spinning and ring twisting frames Flange rings T and SF and their travellers《纺织机械和附件 环锭细纱机和环锭捻线机用钢领.pdf
  • BS ISO 96-2-2009 Textile machinery and accessories - Rings and travellers for ring spinning and ring twisting frames - HZ- and J-rings and their travellers《纺织机械和附件 环锭细纱机和环锭捻线机用钢领和钢.pdf BS ISO 96-2-2009 Textile machinery and accessories - Rings and travellers for ring spinning and ring twisting frames - HZ- and J-rings and their travellers《纺织机械和附件 环锭细纱机和环锭捻线机用钢领和钢.pdf
  • BS ISO 9609-2016 Aerospace - Nuts hexagonal plain reduced height normal across flats with MJ threads classifications 450 MPa (at ambient temperature) 120 degrees C 450 MPa (at ambi.pdf BS ISO 9609-2016 Aerospace - Nuts hexagonal plain reduced height normal across flats with MJ threads classifications 450 MPa (at ambient temperature) 120 degrees C 450 MPa (at ambi.pdf
  • BS ISO 9611-1996 Acoustics - Characterization of sources of structure-borne sound with respect to sound radiation from connected structures - Measurement of velocity at the contact.pdf BS ISO 9611-1996 Acoustics - Characterization of sources of structure-borne sound with respect to sound radiation from connected structures - Measurement of velocity at the contact.pdf
  • 相关搜索

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

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