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

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

1、三级信息管理技术机试-183 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 in15.dat 中存有 200 个 4 位数,并已调用读函数 readDat()把这些数存人数组 a 中,请编制一函数 jsVal(),其功能是:若一个 4 位数的千位数字小于等于百位数字,百位数字小于等于十位数字,以及十位数字小于等于个位数字,并且此 4 位数是偶数,则统计出满足此条件的数的个数 ent 并把这些 4 位数按从小大的顺序存人数组 b 中,最后调用写函数 writeDat()把结果 cnt 及数组 b 中符合条件的4 位数输出到 o

2、ut15.dat 文件中。注意:部分源程序已给出。程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序#includestdio.h#define HAX 200int aHAX,bNAX,cnt=0;void writeDat();voidjsVal()void readDat()int i;FILE*fp;fp=fopen(“in15.dat“,“r“);for(i=0;iMAX;i+)fscanf(fp,“% d“,fclose(fp);voidmain()int i;readDa

3、t();jsVal();printf(“满足条件的数=% d/n“,cnt);for(i=0;icnt;i+)printf(“% d/n“,bi);writeDat();void writeDat()FILE *fp;int i;fp=fopen(“out15.dat“,“w“);fprintf(fp,“% d/n“,cnt);for(i=0;icnt;i+)fprintf(fp,“% d/n“,bi);fclose(fp);(分数:100.00)_三级信息管理技术机试-183 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 i

4、n15.dat 中存有 200 个 4 位数,并已调用读函数 readDat()把这些数存人数组 a 中,请编制一函数 jsVal(),其功能是:若一个 4 位数的千位数字小于等于百位数字,百位数字小于等于十位数字,以及十位数字小于等于个位数字,并且此 4 位数是偶数,则统计出满足此条件的数的个数 ent 并把这些 4 位数按从小大的顺序存人数组 b 中,最后调用写函数 writeDat()把结果 cnt 及数组 b 中符合条件的4 位数输出到 out15.dat 文件中。注意:部分源程序已给出。程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动主函数 main()、读函数 r

5、eadDat()和写函数 writeDat()的内容。试题程序#includestdio.h#define HAX 200int aHAX,bNAX,cnt=0;void writeDat();voidjsVal()void readDat()int i;FILE*fp;fp=fopen(“in15.dat“,“r“);for(i=0;iMAX;i+)fscanf(fp,“% d“,fclose(fp);voidmain()int i;readDat();jsVal();printf(“满足条件的数=% d/n“,cnt);for(i=0;icnt;i+)printf(“% d/n“,bi);

6、writeDat();void writeDat()FILE *fp;int i;fp=fopen(“out15.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; /

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

展开阅读全文
相关资源
猜你喜欢
  • BS EN 10211-2013 Chemical analysis of ferrous materials Determination of titanium in steels and cast irons Flame atomic absorption spectrometric method《黑色金属材料的化学分析 钢和铸铁中钛含量的测定 火焰原子.pdf BS EN 10211-2013 Chemical analysis of ferrous materials Determination of titanium in steels and cast irons Flame atomic absorption spectrometric method《黑色金属材料的化学分析 钢和铸铁中钛含量的测定 火焰原子.pdf
  • BS EN 10212-1996 Chemical analysis of ferrous materials - Determination of arsenic in steel and iron - Spectrophotometric method《铁材料的化学分析 测定钢和铁中砷的含量 分光光度法》.pdf BS EN 10212-1996 Chemical analysis of ferrous materials - Determination of arsenic in steel and iron - Spectrophotometric method《铁材料的化学分析 测定钢和铁中砷的含量 分光光度法》.pdf
  • BS EN 10213-2007 Steel castings for pressure purposes《压力用钢铸件》.pdf BS EN 10213-2007 Steel castings for pressure purposes《压力用钢铸件》.pdf
  • BS EN 10216-1-2013 Seamless steel tubes for pressure purposes Technical delivery conditions Non-alloy steel tubes with specified room temperature properties《承压用无缝钢管 交货技术条件 规定了室温特性的.pdf BS EN 10216-1-2013 Seamless steel tubes for pressure purposes Technical delivery conditions Non-alloy steel tubes with specified room temperature properties《承压用无缝钢管 交货技术条件 规定了室温特性的.pdf
  • BS EN 10216-2-2013 Seamless steel tubes for pressure purposes Technical delivery conditions Non-alloy and alloy steel tubes with specified elevated temperature properties《承压用无缝钢管 交.pdf BS EN 10216-2-2013 Seamless steel tubes for pressure purposes Technical delivery conditions Non-alloy and alloy steel tubes with specified elevated temperature properties《承压用无缝钢管 交.pdf
  • BS EN 10216-3-2013 Seamless steel tubes for pressure purposes Technical delivery conditions Alloy fine grain steel tubes《承压用的无缝钢管 交付技术条件 合金细晶粒钢管》.pdf BS EN 10216-3-2013 Seamless steel tubes for pressure purposes Technical delivery conditions Alloy fine grain steel tubes《承压用的无缝钢管 交付技术条件 合金细晶粒钢管》.pdf
  • BS EN 10216-4-2013 Seamless steel tubes for pressure purposes Technical delivery conditions Non-alloy and alloy steel tubes with specified low temperature properties《承压用无缝钢管 交付技术条件.pdf BS EN 10216-4-2013 Seamless steel tubes for pressure purposes Technical delivery conditions Non-alloy and alloy steel tubes with specified low temperature properties《承压用无缝钢管 交付技术条件.pdf
  • BS EN 10216-5-2013 Seamless steel tubes for pressure purposes Technical delivery conditions Stainless steel tubes《压力无缝钢管 交货技术条件 不锈钢管》.pdf BS EN 10216-5-2013 Seamless steel tubes for pressure purposes Technical delivery conditions Stainless steel tubes《压力无缝钢管 交货技术条件 不锈钢管》.pdf
  • BS EN 10217-1-2002 Welded steel tubes for pressure purposes - Technical delivery conditions - Non-alloy steel tubes with specified room temperature properties《承压用焊接钢管 交付技术状态 规定室温特性.pdf BS EN 10217-1-2002 Welded steel tubes for pressure purposes - Technical delivery conditions - Non-alloy steel tubes with specified room temperature properties《承压用焊接钢管 交付技术状态 规定室温特性.pdf
  • 相关搜索

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

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