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

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

1、三级信息管理技术机试-180 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 INl9DAT 中存有 200个 4位数,并已调用读函数 readDat()把这些数存入数组 a中,请编制一函数 jsVal(),其功能是:把一个 4位数的千位数字减百位数字再减十位数字最后减个位数字,如果得出的值大于等于零且此 4位数是奇数,则统计出满足此条件的数的个数 cnt并把这些 4位数存入数组b中,然后对数组 b中的 4位数按从小到大的顺序进行排序,最后调用函数 wnteDat()把结果 cnt及数组b中符合条件的 4位数输出到 out19

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

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

4、文件 INl9DAT 中存有 200个 4位数,并已调用读函数 readDat()把这些数存入数组 a中,请编制一函数 jsVal(),其功能是:把一个 4位数的千位数字减百位数字再减十位数字最后减个位数字,如果得出的值大于等于零且此 4位数是奇数,则统计出满足此条件的数的个数 cnt并把这些 4位数存入数组b中,然后对数组 b中的 4位数按从小到大的顺序进行排序,最后调用函数 wnteDat()把结果 cnt及数组b中符合条件的 4位数输出到 out19.dat文件中。注意:部分源程序已给出。程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动主函数 main()、读函数 re

5、adDat()和写函数 wfiteDat()的内容。试题程序#includestdio.h#define MAX 200int aMAX,bMAX,cnt=0;void writeDat();void jsVal()void readDat()int i;FILE*fP;fP=fopen(“IN19.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“,bi);pr

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

7、000; /*求 4位数的千位数字*/a3=ai%1000/100; /*求 4位数的百位数字*/a2=ai%100/10; /*求 4位数的十位数字*/a1=ai%10; /*求 4位数的个位数字*/if(a4-a3-a2-a1=0) /*则将该数存入数组 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中的数进行从小到大的排序。首先要找出满足条件的数,其关键在于判断每个数的千位数字减百位数字减十位数字减个位数字的差是否大于等于零,并且此 4位数是否为奇数。其次,将满足条件的数存入数组 b中,并用变量 cnt来统计数组 b中元素的个数。最后,将所有满足条件的数取出后利用选择法进行排序,即将当前元素依次同它后面的元素进行比较,发现小于该数的数,就进行交换。

展开阅读全文
相关资源
猜你喜欢
  • BS EN 14175-2-2003 Fume cupboards Safety and performance requirements《通风橱 安全性和性能要求》.pdf BS EN 14175-2-2003 Fume cupboards Safety and performance requirements《通风橱 安全性和性能要求》.pdf
  • BS EN 14175-7-2012 Fume cupboards Fume cupboards for high heat and acidic load《通风橱 高温和强酸性负载用通风橱》.pdf BS EN 14175-7-2012 Fume cupboards Fume cupboards for high heat and acidic load《通风橱 高温和强酸性负载用通风橱》.pdf
  • BS EN 14176-2017 Foodstuffs Determination of domoic acid in raw shellfish raw finfish and cooked mussels by RP-HPLC using UV detection《食品 采用使用UV检测的RP-HPLC测定生贝 生有鳍鱼和熟贻贝中的软骨藻酸》.pdf BS EN 14176-2017 Foodstuffs Determination of domoic acid in raw shellfish raw finfish and cooked mussels by RP-HPLC using UV detection《食品 采用使用UV检测的RP-HPLC测定生贝 生有鳍鱼和熟贻贝中的软骨藻酸》.pdf
  • BS EN 14177-2004 Foodstuffs - Determination of patulin in clear and cloudy apple juice and puree - HPLC method with liquid liquid partition clean-up《食品 澄清和混浊苹果汁和果泥中棒曲霉素的测定 液体或液体分溶提.pdf BS EN 14177-2004 Foodstuffs - Determination of patulin in clear and cloudy apple juice and puree - HPLC method with liquid liquid partition clean-up《食品 澄清和混浊苹果汁和果泥中棒曲霉素的测定 液体或液体分溶提.pdf
  • BS EN 14178-1-2004 Glass in building - Basic alkaline earth silicate glass - Float glass《建筑物用玻璃 基本碱土硅酸盐玻璃 平板玻璃》.pdf BS EN 14178-1-2004 Glass in building - Basic alkaline earth silicate glass - Float glass《建筑物用玻璃 基本碱土硅酸盐玻璃 平板玻璃》.pdf
  • BS EN 14178-2-2004 Glass in building - Basic alkaline earth silicate glass products - Evaluation of conformity Product standard《建筑物用玻璃 基本碱土硅酸盐玻璃制品 合格评价 产品标准》.pdf BS EN 14178-2-2004 Glass in building - Basic alkaline earth silicate glass products - Evaluation of conformity Product standard《建筑物用玻璃 基本碱土硅酸盐玻璃制品 合格评价 产品标准》.pdf
  • BS EN 14179-1-2016 Glass in building Heat soaked thermally toughened soda lime silicate safety glass Definition and description《建筑物玻璃 长时间热处理的热钢化钙钠硅酸盐安全玻璃 定义和描述》.pdf BS EN 14179-1-2016 Glass in building Heat soaked thermally toughened soda lime silicate safety glass Definition and description《建筑物玻璃 长时间热处理的热钢化钙钠硅酸盐安全玻璃 定义和描述》.pdf
  • BS EN 14179-2-2005 Glass in building - Heat-soaked thermally-toughened soda lime silicate safety glass - Evaluation of conformity product standard《建筑物玻璃 长时间热处理的热钢化钙钠硅酸盐安全玻璃 合格评定 产品.pdf BS EN 14179-2-2005 Glass in building - Heat-soaked thermally-toughened soda lime silicate safety glass - Evaluation of conformity product standard《建筑物玻璃 长时间热处理的热钢化钙钠硅酸盐安全玻璃 合格评定 产品.pdf
  • BS EN 14180-2014 Sterilizers for medical purposes Low temperature steam and formaldehyde sterilizers Requirements and testing《医用灭菌器 低温蒸汽和甲醛灭菌器 要求和试验》.pdf BS EN 14180-2014 Sterilizers for medical purposes Low temperature steam and formaldehyde sterilizers Requirements and testing《医用灭菌器 低温蒸汽和甲醛灭菌器 要求和试验》.pdf
  • 相关搜索

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

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