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

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

1、三级信息管理技术机试-185 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN13.DAT 中存有 200 个 4 位数,并已调用读函数 readDat()把这些数存人数组 a 中,请编制一函数 jsVal(),其功能是:如果 4 位数各位上的数字均是 0 或 2 或 4 或 6 或 8,则统计出满足此条件的数的个数 cnt,并把这些 4 位数按从大到小的顺序存入数组 b 中,最后调用写函数 writeDat()把结果cnt 及数组 b 中符合条件的 4 位数输出到 OUT13.DAT 文件中。注意:部分源程序已给出。程序

2、中已定义数组: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(“IN13,DAT“,“r“);for(i=0;iMAX;i+) fscanf(fp,“%d“,fclose(fp);voidmain()int i;readDat();jVal();printf(“满足条件的数=

3、d/n“,cnt);for(i=0;icnt;i+)printf(“%d“,bi);printf(“/n“);writeDat();void writeDat()FILE*fp;int i;fP=fopen(“OUT13.DAT“,“w“);fprintf(fp,:% d/n“,cnt);for(i=0;icnt;i+)fprintf(fp,“% d/n“,bi);fclose(fp);(分数:100.00)_三级信息管理技术机试-185 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN13.DAT 中存有 200 个 4

4、 位数,并已调用读函数 readDat()把这些数存人数组 a 中,请编制一函数 jsVal(),其功能是:如果 4 位数各位上的数字均是 0 或 2 或 4 或 6 或 8,则统计出满足此条件的数的个数 cnt,并把这些 4 位数按从大到小的顺序存入数组 b 中,最后调用写函数 writeDat()把结果cnt 及数组 b 中符合条件的 4 位数输出到 OUT13.DAT 文件中。注意:部分源程序已给出。程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序#includestdio.h

5、define MAX 200int aMAX,bMAX,cnt=0;void writeDat();void jsVal()void readDat()int i;FILE*fp;fp=fopen(“IN13,DAT“,“r“);for(i=0;iMAX;i+) fscanf(fp,“%d“,fclose(fp);voidmain()int i;readDat();jVal();printf(“满足条件的数=%d/n“,cnt);for(i=0;icnt;i+)printf(“%d“,bi);printf(“/n“);writeDat();void writeDat()FILE*fp;int

6、 i;fP=fopen(“OUT13.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; /*定义数据交换时的暂存变量*/for(i=0;i200;i+) /*逐个取每一个 4 位数*/a4=ai/1000; /*求 4 位数的千位数字*/a3=ai%1000/100; /*求 4 位数

7、的百位数字*/a2=ai%100/10; /*求 4 位数的十位数字*/a1=ai%10; /*求 4 位数的个位数字*/if(a4%2=0 /*将满足条件的数存入数组 b 中*/cnt+; /*统计满足条件的数的个数 cnt*/for(i=0;icnt-1;i+) /*将数组 b 中的数按从大到小的顺序排序*/for(j=i+1;jcnt;j+)if(bibj)temp=bi;bi=bj;bj=temp;)解析:解析 根据题意可知,函数 jsVal()要实现两个功能:一是找出满足条件的那些数,并将其存放在数组 b 中;二是对数组 b 中的数进行从大到小的排序。首先找出满足条件的数,其关键在于对每个数的每一位的值进行是否为偶数的判断,即各位上的数字均是O 或 2 或 4 或 6 或 8。其次,将满足条件的数存人数组 b 中,并用变量 cnt 来统计数组 b 中元素的个数。最后,将所有满足条件的数取出后利用选择法进行排序,即将当前元素依次同它后面的元素进行比较,发现有大于该数的数,就将这两数进行交换。

展开阅读全文
相关资源
猜你喜欢
  • BS ISO 22968-2010 Forced draught oil burners《强制汲出燃油器》.pdf BS ISO 22968-2010 Forced draught oil burners《强制汲出燃油器》.pdf
  • BS ISO 22972-2004 Essential oils - Analysis by gas chromatography on chiral capillary columns - General method《香精油 手性毛细管柱气相色谱法分析 一般方法》.pdf BS ISO 22972-2004 Essential oils - Analysis by gas chromatography on chiral capillary columns - General method《香精油 手性毛细管柱气相色谱法分析 一般方法》.pdf
  • BS ISO 230-1-2012 Test code for machine tools Geometric accuracy of machines operating under no-load or quasi-static conditions《机床试验法规 在空载或精加工条件下机床工作的几何精度》.pdf BS ISO 230-1-2012 Test code for machine tools Geometric accuracy of machines operating under no-load or quasi-static conditions《机床试验法规 在空载或精加工条件下机床工作的几何精度》.pdf
  • BS ISO 230-10-2016 Test code for machine tools Determination of the measuring performance of probing systems of numerically controlled machine tools《机床试验规程 数控机床探测系统测量性能的测定》.pdf BS ISO 230-10-2016 Test code for machine tools Determination of the measuring performance of probing systems of numerically controlled machine tools《机床试验规程 数控机床探测系统测量性能的测定》.pdf
  • BS ISO 230-2-2014 Test code for machine tools Determination of accuracy and repeatability of positioning of numerically controlled axes《机床试验规程 数控轴定位精度和重复性的测定》.pdf BS ISO 230-2-2014 Test code for machine tools Determination of accuracy and repeatability of positioning of numerically controlled axes《机床试验规程 数控轴定位精度和重复性的测定》.pdf
  • BS ISO 230-3-2007 Test code for machine tools Determination of thermal effects《机床试验规程 热效果的测定》.pdf BS ISO 230-3-2007 Test code for machine tools Determination of thermal effects《机床试验规程 热效果的测定》.pdf
  • BS ISO 230-4-2005 Test code for machine tools - Circular tests for numerically controlled machine tools《机床检验通则 数控机床的圆检验》.pdf BS ISO 230-4-2005 Test code for machine tools - Circular tests for numerically controlled machine tools《机床检验通则 数控机床的圆检验》.pdf
  • BS ISO 230-5-2000 Test code for machine tools Determination of the noise emission《机床测试规范 噪声辐射的测定》.pdf BS ISO 230-5-2000 Test code for machine tools Determination of the noise emission《机床测试规范 噪声辐射的测定》.pdf
  • BS ISO 230-6-2002 Test code for machine tools - Determination of positioning accuracy on body and face diagonals (Diagonal displacement tests)《机床试验规范 床身和床面对角线上的精确位置的测定》.pdf BS ISO 230-6-2002 Test code for machine tools - Determination of positioning accuracy on body and face diagonals (Diagonal displacement tests)《机床试验规范 床身和床面对角线上的精确位置的测定》.pdf
  • 相关搜索

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

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