【计算机类职业资格】三级网络技术机试-231及答案解析.doc

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

1、三级网络技术机试-231 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN.DAT 中存有 200 个四位数,并已调用读函数 readDat()把这些数存入数组 a 中,请考生编制一个函数 jsVal(),其功能是:依次从数组 a 中取出一个四位数,如果该四位数大于该四位数以后的连续 5 个数且该数是奇数(该四位数以后不满 5 个数,则不统计),则统计出满足此条件的个数 cnt 并把这些四位数按从小到大的顺序存入数组 b 中,最后调用写函数 writeDat()把结果 cnt 和数组 b 中符合条件的四位数输出到 OUT.

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

3、id main()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(“out.dat“,“w”);fprintf(fp,“%d/n”,cnt);for(i=0;icnt;i+)fprintf(fp,“%d/n“,bi);fclose(fp);(分数:100.00)_三级网络技术机试-231 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题

4、数:1,分数:100.00)1.已知数据文件 IN.DAT 中存有 200 个四位数,并已调用读函数 readDat()把这些数存入数组 a 中,请考生编制一个函数 jsVal(),其功能是:依次从数组 a 中取出一个四位数,如果该四位数大于该四位数以后的连续 5 个数且该数是奇数(该四位数以后不满 5 个数,则不统计),则统计出满足此条件的个数 cnt 并把这些四位数按从小到大的顺序存入数组 b 中,最后调用写函数 writeDat()把结果 cnt 和数组 b 中符合条件的四位数输出到 OUT.DAT 文件中。注意:部分源程序存在文件 PROG1.C 文件中。程序中已定义数组:a200,b

5、200,已定义变量:cnt。请勿改动数据文件 IN.DAT 中的任何数据、主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序#include #define MAX 200int aMAX,bMAX,cnt=0;void writeDat();void jsVal()void readDat()int i;FILE *fp;fp=fopen(“in.dat“,“r“);for(i=0;iMAX;i+)fscanf(fp,“%d“,fclose(fp);void main()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(“out.dat“,“w”);fprintf(fp,“%d/n”,cnt);for(i=0;icnt;i+)fprintf(fp,“%d/n“,bi);fclose(fp);(分数:100.00)_正确答案:(void jsVal()(inf i,j; /*定义变量*/int temp;for(i=0;iMAX-5;i+)if(ai%2=1for(i=0;icnt-1;i+) /*选择法排序*/for(j=i+1;jcnt;j+)if(bibj)temp=bi;bi=bj;bj=temp;)解析:解析 本题要求先将已知数按照一定的判断条件与数组中相邻的连续几个数进行比较,筛选统计后再按大小进行排序。依据题意,应依次从数组 a 中取出每一个四位数,依次与以后的连续 5 个数比较,根据题目中给出的判断条件(该四位数大于该四位数以后的连续 5 个数且该数是奇数,即 ai%2=1&aiai+1&aiai+2&aiai+3&aiai+4&aiai+5)筛选后,将符合条件的四位数存入数组 b 中,同时计数器变量 cnt 加 1,最后将数组 b 中的四位数用选择法进行排序。

展开阅读全文
相关资源
猜你喜欢
  • DS EN 510-1994 Specification for protective colthing for use where there is a risk of entanglement with moving parts《有被运动机件缠绕危险处穿着的防护服规范》.pdf DS EN 510-1994 Specification for protective colthing for use where there is a risk of entanglement with moving parts《有被运动机件缠绕危险处穿着的防护服规范》.pdf
  • DS EN 526-1993 Inland navigation vessels Gangways with a length not exceeding 8 m Requirements types《内河航行船舶 长度不超过8米的跳板 要求,类型》.pdf DS EN 526-1993 Inland navigation vessels Gangways with a length not exceeding 8 m Requirements types《内河航行船舶 长度不超过8米的跳板 要求,类型》.pdf
  • DS EN 60041-1995 Field acceptance tests to determine the hydraulic performance of hydraulic turbines storage pumps and pump-turbines《测定水轮机,蓄水泵和水泵水轮机液压性能的现场验收试验》.pdf DS EN 60041-1995 Field acceptance tests to determine the hydraulic performance of hydraulic turbines storage pumps and pump-turbines《测定水轮机,蓄水泵和水泵水轮机液压性能的现场验收试验》.pdf
  • DS EN 60094-5-1995 Magnetic tape sound recording and reproducing systems - Part 5 Electrical magnetic tape properties《磁带录音和放音系统 第5节:磁带电特性》.pdf DS EN 60094-5-1995 Magnetic tape sound recording and reproducing systems - Part 5 Electrical magnetic tape properties《磁带录音和放音系统 第5节:磁带电特性》.pdf
  • DS EN 60094-7-1995 Magnetic tape sound recording and reproducing systems - Part 7 Cassette for commercial tape records and domestic use《磁带录音和放音系统 第7节:商业录音和家用盒式磁带》.pdf DS EN 60094-7-1995 Magnetic tape sound recording and reproducing systems - Part 7 Cassette for commercial tape records and domestic use《磁带录音和放音系统 第7节:商业录音和家用盒式磁带》.pdf
  • DS EN 60154-1+A1-1995 Flanges for waveguids - Part 1 General requirements《波导管法兰 第1部分:一般要求》.pdf DS EN 60154-1+A1-1995 Flanges for waveguids - Part 1 General requirements《波导管法兰 第1部分:一般要求》.pdf
  • DS EN 60168-1995 Test of indoor and outdoor post insulators of ceramic material or glass for systems with nominal voltages greater than 1000 V《标称电压大于1000V系统的室内,外陶瓷材料或玻璃支柱绝缘子的试验》.pdf DS EN 60168-1995 Test of indoor and outdoor post insulators of ceramic material or glass for systems with nominal voltages greater than 1000 V《标称电压大于1000V系统的室内,外陶瓷材料或玻璃支柱绝缘子的试验》.pdf
  • DS EN 60172-1995 Test procedure for the determination of the temperature index of enamelled winding wires《测定绕组漆包线温度系数的试验程序》.pdf DS EN 60172-1995 Test procedure for the determination of the temperature index of enamelled winding wires《测定绕组漆包线温度系数的试验程序》.pdf
  • DS EN 60264-1-1995 Packaging of winding wires - Part 1 Containers for round winding wires《绕组线的包装 第1部分:圆形绕组线容器》.pdf DS EN 60264-1-1995 Packaging of winding wires - Part 1 Containers for round winding wires《绕组线的包装 第1部分:圆形绕组线容器》.pdf
  • 相关搜索

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

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