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

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

1、三级信息管理技术机试-181 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN17.DAT中存有 300个 4位数,并已调用读函数 readDat()把这些数存入数组 a中,请编制一函数 jsValue(),其功能是:求出个位数上的数减千位数上数减百位数上的数减十位数上的数大于零的个数 cnt,再把所有满足此条件的 4位数依次存人数组 b中,然后对数组 b中的 4位数按从大到小的顺序进行排序,最后调用函数 wfiteDat()把数组 b中的数输出到 OUT17.DAT文件中。例如:1239,9-1-2-30,则该数满足条件

2、存入数组 b中,且个数 cnt=cnt+1。8129,9-8-1-20,则该数不满足条件,忽略。注意:部分源程序已给出。程序中已定义数组:a300,b300,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序#includestdio.hint a300,b300,cnt=0;void readDat();void writeDat();void jsValue()voidmain()int i;readDat();jsValue();writeDat();printf(“cnt=% d/n“,cnt);for(i=0;

3、icnt;i+)printf(“b%d=%d/n“,i,bi);void readDat()FILE*fp;int i;fp=fopen(“IN17.DAT“,“r“);for(i=0;i300;i+)fscanf(fp,“%d,“,fclose(fp);void writeDat()FILE*fp;int i;fp=fopen(“OUT17.DAT“,“w“);fprintf(fp,“% d/n“,cnt);for(i=0;icnt;i+)fprintf(fp,“% d/n“,bi);fclose(fp);(分数:100.00)_三级信息管理技术机试-181 答案解析(总分:100.00,做

4、题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN17.DAT中存有 300个 4位数,并已调用读函数 readDat()把这些数存入数组 a中,请编制一函数 jsValue(),其功能是:求出个位数上的数减千位数上数减百位数上的数减十位数上的数大于零的个数 cnt,再把所有满足此条件的 4位数依次存人数组 b中,然后对数组 b中的 4位数按从大到小的顺序进行排序,最后调用函数 wfiteDat()把数组 b中的数输出到 OUT17.DAT文件中。例如:1239,9-1-2-30,则该数满足条件,存入数组 b中,且个数 cnt=cnt+1。8129,9-8-

5、1-20,则该数不满足条件,忽略。注意:部分源程序已给出。程序中已定义数组:a300,b300,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序#includestdio.hint a300,b300,cnt=0;void readDat();void writeDat();void jsValue()voidmain()int i;readDat();jsValue();writeDat();printf(“cnt=% d/n“,cnt);for(i=0;icnt;i+)printf(“b%d=%d/n“,i,bi);

6、void readDat()FILE*fp;int i;fp=fopen(“IN17.DAT“,“r“);for(i=0;i300;i+)fscanf(fp,“%d,“,fclose(fp);void writeDat()FILE*fp;int i;fp=fopen(“OUT17.DAT“,“w“);fprintf(fp,“% d/n“,cnt);for(i=0;icnt;i+)fprintf(fp,“% d/n“,bi);fclose(fp);(分数:100.00)_正确答案:(void jsValue()inti,j; /*定义循环控制变量*/int a1,a2,a3,a4; /*定义变量

7、保存 4位数的每位数字*/int temp; /*定义数据交换时的暂存变量*/for(i=0;i300;i+) /*逐个取每一个 4位数*/a4=ai/1000; /*求 4位数的千位数字*/a3=ai%1000/100; /*求 4位数的百位数字*/a2=ai%100/10; /*求 4位数的十位数字*/a1=ai%10; /*求 4位数的个位数字*/if(a1-a4-a3*a20) /*如果个位数字减千位数字减百位数字减十位数字零*/bcnt=ai; /*则将满足条件的数存入数组 b中*/cnt+; /*统计满足条件的数的个数*/for(i=0;icnt-1:i+) /*对数组 b的 4位

8、数按从大到小的顺序进行排序*/for(j=i+1;jcnt;j+)if(bibj)temp=bi;bi=bj;bj=temp;)解析:解析 根据题意可知,函数 jsValue()要实现两个功能:一是找出满足条件的那些数,并存放在数组 b中;二是对数组 b中的数进行从大到小的排序。首先要找出满足条件的数,关键在于判断每个数的个位数字减千位数字减百位数字减十位数字的差是否大于零,这里可以通过一个 if语句来进行判断。其次,将满足条件的数存入数组 b中,并用变量 cnt来统计数组 b中元素的个数。最后,将所有满足条件的数取出后利用选择法进行排序,即将当前元素依次同它后面的元素进行比较,发现大于该数的数,就进行交换。

展开阅读全文
相关资源
猜你喜欢
  • STAS SR ISO 8130-8-1966 Coating powders - Part 8 Assessment of the storage stability of thermosetting powders《粉末涂料 第8部分:热固性粉末的存储稳定性的评估》.pdf STAS SR ISO 8130-8-1966 Coating powders - Part 8 Assessment of the storage stability of thermosetting powders《粉末涂料 第8部分:热固性粉末的存储稳定性的评估》.pdf
  • STAS SR ISO 8130-9-1992 Coating powders -Part 9 Sampling《粉末涂料,第9部分:采样 》.pdf STAS SR ISO 8130-9-1992 Coating powders -Part 9 Sampling《粉末涂料,第9部分:采样 》.pdf
  • STAS SR ISO 8157-1984 Fertilizers and soil conditioners Vocabulary《肥料和土壤调理 词汇表 》.pdf STAS SR ISO 8157-1984 Fertilizers and soil conditioners Vocabulary《肥料和土壤调理 词汇表 》.pdf
  • STAS SR ISO 8178-3-1996 Reciprocating internai combustion engines - Exhaust emission measurement - Part 3 Definitions and methods of measure-ment of exhaust gas smoke under steady-.pdf STAS SR ISO 8178-3-1996 Reciprocating internai combustion engines - Exhaust emission measurement - Part 3 Definitions and methods of measure-ment of exhaust gas smoke under steady-.pdf
  • STAS SR ISO 8189-1995 Solid fertilizers - Determination of moisture content - Gravimetric method by drying under reduced pressure《固体肥料 水分含量测定 减压干燥下的重量测定法 》.pdf STAS SR ISO 8189-1995 Solid fertilizers - Determination of moisture content - Gravimetric method by drying under reduced pressure《固体肥料 水分含量测定 减压干燥下的重量测定法 》.pdf
  • STAS SR ISO 8190-1996 Solid fertilizers - Determination of moisture content - Gravimetric method by drying at (105 ± 2)°C《固体肥料 水分含量的测定 通过在(105 ± 2)°C干燥的重量法 》.pdf STAS SR ISO 8190-1996 Solid fertilizers - Determination of moisture content - Gravimetric method by drying at (105 ± 2)°C《固体肥料 水分含量的测定 通过在(105 ± 2)°C干燥的重量法 》.pdf
  • STAS SR ISO 8191-1-1995 Fumiture-Assessment of the ignitability of upholstered furniture Part 1 Ignition source smouldering cigarette《装饰家具着火性的评估 第1部分:火源燃着的香烟 》.pdf STAS SR ISO 8191-1-1995 Fumiture-Assessment of the ignitability of upholstered furniture Part 1 Ignition source smouldering cigarette《装饰家具着火性的评估 第1部分:火源燃着的香烟 》.pdf
  • STAS SR ISO 8191-2-1995 Furniture Assessment of ignitability of upholstered furniture Part 2 Ignition source match - flame equivalent《家具 装饰家具着火性的评估,第2部分:火柴 类似点火源》.pdf STAS SR ISO 8191-2-1995 Furniture Assessment of ignitability of upholstered furniture Part 2 Ignition source match - flame equivalent《家具 装饰家具着火性的评估,第2部分:火柴 类似点火源》.pdf
  • STAS SR ISO 8205-3-1996 Water-cooled secondary connection cables for resistance welding -Part 3 Test requirements《电阻焊接的冷水式二次连接电缆 第3部分:测试要求》.pdf STAS SR ISO 8205-3-1996 Water-cooled secondary connection cables for resistance welding -Part 3 Test requirements《电阻焊接的冷水式二次连接电缆 第3部分:测试要求》.pdf
  • 相关搜索

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

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