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

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

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

2、请勿改动主函数 main()、读函数 readDat()和写函数 wiltedat()的内容。试题程序:#includestdio.h#define MAX 200int aMAX,bMAX,cnt=0;void jsVal()void readDat() int i;FILE *fp;fp=fopen(“in53.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

3、bi);printf(“/n“);writeDat();writeDat()FILE *fp;int i;fp=foPen(“out53.dat“,“w“);fprintf(fp,“%d/n“,cnt);for(i=0;icnt;i+)fprintf(fp,“%d/n“,bi);fclose(fp);(分数:100.00)_三级网络技术机试-35 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN53.DAT 中存有 200 个 4 位数,并已调用读函数 readDat()把这些数存入数组 a 中,请编制一函数 isVal

4、),其功能是:依次从数组 a 中取出一个 4 位数,如果该 4 位数连续大于该 4 位数以前的 5 个数且该数是偶数,则统计出满足此条件的数个数 cnt 并把这些 4 位数按从大到小的顺序存入数组 b中,最后调用写函数 writeDat()把结果 cnt 及数组 b 中符合条件的 4 位数输出到文件 OUT53.DAT 中。请勿改动主函数 main()、读函数 readDat()和写函数 wiltedat()的内容。试题程序:#includestdio.h#define MAX 200int aMAX,bMAX,cnt=0;void jsVal()void readDat() int i;F

5、ILE *fp;fp=fopen(“in53.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);printf(“/n“);writeDat();writeDat()FILE *fp;int i;fp=foPen(“out53.dat“,“w“);fprintf(fp,“%d/n“,cnt);for(i=0;icnt;i+)fprintf(fp,“%d/n

6、bi);fclose(fp);(分数:100.00)_正确答案:(void jsVal() int i,j,flag;for (i=5; iMAX; i+)for(j=i-5;ji;j+)if(aiaj) /*如果该 4 位数连续大于它以前的 5 个数*/flag=l; /*则置 flag 为 1*/else flag=0; /*否则置 flag 为 0*/if (ai%2!=0) /*如果该四位数为奇数*/flag=0; /*则置 flag 为 0*/if (flag=O)break; /*如果 flag 为 0, 则退出循环*/if (flag=1) bcnt =ai; /*把满足条件

7、的数存入数组 b 中*/cnt+; /*统计满足条件的数的个数*/for (i=0; icnt-1; i+) /*将数组 b 中的数按从大到波折顺序排列*/for ( j =i+l; j cnt; j +)if(bibj ) flag=bi;bi=bj;bj=flag;)解析:解析本题考查的知识点如下:(1)使用循环对数组的元素进行比较和排序。(2)强行退出循环结构。在本题中,数组 b 中的数据要满足的条件有两个。在这里,不再使用判断结构中条件的布尔运算,而采用一种新的方法设置标志变量 flag。当数据不满足某一条件时,如数据不是偶数,将 flag 设置为 0:当 flag 等于 0 时,可直接退出本层循环结构,进入外层的循环中。否则,根据题意要求,将数据存入数组 b 中。对数组 b 中的数据排序,使用“选择排序法”。

展开阅读全文
相关资源
猜你喜欢
  • IEC 61512-3-2008 Batch control - Part 3 General and site recipe models and representation《批量控制.第3部分 一般和现场制法模型及表示》.pdf IEC 61512-3-2008 Batch control - Part 3 General and site recipe models and representation《批量控制.第3部分 一般和现场制法模型及表示》.pdf
  • IEC 61514-2-2013 Industrial Process Control Systems - Part 2 Methods of evaluating the performance of intelligent valve positioners with pneumatic outputs《工业过程控制系统 第2部分 气动输出智能阀门定位器性能的评估方法》.pdf IEC 61514-2-2013 Industrial Process Control Systems - Part 2 Methods of evaluating the performance of intelligent valve positioners with pneumatic outputs《工业过程控制系统 第2部分 气动输出智能阀门定位器性能的评估方法》.pdf
  • IEC 61514-2000 Industrial-process control systems - Methods of evaluating the performance of valve positioners with pneumatic outputs《工业过程控制系统 气动输出阀门定位器性能评定方法》.pdf IEC 61514-2000 Industrial-process control systems - Methods of evaluating the performance of valve positioners with pneumatic outputs《工业过程控制系统 气动输出阀门定位器性能评定方法》.pdf
  • IEC 61518-2001 Mating dimensions between differential pressure (type) measuring instruments and flanged-on shut-off devices up to 413 bar (41 3 MPa)《413BAR(41.3MPa)及以下的压差(型)测量仪表与装上凸缘的关停器件间的配合尺寸》.pdf IEC 61518-2001 Mating dimensions between differential pressure (type) measuring instruments and flanged-on shut-off devices up to 413 bar (41 3 MPa)《413BAR(41.3MPa)及以下的压差(型)测量仪表与装上凸缘的关停器件间的配合尺寸》.pdf
  • IEC 61520-2000 Metal thermowells for thermometer sensors - Functional dimensions《温度计敏感器用金属温度计套管 功能尺寸》.pdf IEC 61520-2000 Metal thermowells for thermometer sensors - Functional dimensions《温度计敏感器用金属温度计套管 功能尺寸》.pdf
  • IEC 61523-1-2012 Delay and power calculation standards - Part 1 Integrated circuit delay and power calculation systems《延迟和电力计算标准.第1部分 集成电路延迟系统和电力计算系统》.pdf IEC 61523-1-2012 Delay and power calculation standards - Part 1 Integrated circuit delay and power calculation systems《延迟和电力计算标准.第1部分 集成电路延迟系统和电力计算系统》.pdf
  • IEC 61534-1-2011 Powertrack systems - Part 1 General requirements《动力跟踪系统.第1部分 一般要求》.pdf IEC 61534-1-2011 Powertrack systems - Part 1 General requirements《动力跟踪系统.第1部分 一般要求》.pdf
  • IEC 61535 CORR 1-2014 Installation couplers intended for permanent connection in fixed installations Corrigendum 1《固定装置中的固定连接用安装连接器.勘误表1》.pdf IEC 61535 CORR 1-2014 Installation couplers intended for permanent connection in fixed installations Corrigendum 1《固定装置中的固定连接用安装连接器.勘误表1》.pdf
  • IEC 61535 Edition 1.1-2012 Installation couplers intended for permanent connection in fixed installations《固定设备上固定连接用耦合器安装》.pdf IEC 61535 Edition 1.1-2012 Installation couplers intended for permanent connection in fixed installations《固定设备上固定连接用耦合器安装》.pdf
  • 相关搜索

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

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