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

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

1、三级网络技术机试-225 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知文件 IN.DAT 中存有 300 个四位数,并已调用读函数 readDat()把这些数存入数组 a 中,请编制一个函数 isValue(),其功能是:求出所有这些四位数是素数的个数 cnt,再把所有满足此条件的四位数依次存入数组 b 中,然后对数组 b 的四位数按从小到大的顺序进行排序。最后 main()函数调用写函数writeDat()把数组 b 中的数输出到 OUT.DAT 文件。例如,5591 是素数,则该数满足条件存入数组 b 中,且个数 cnt=cnt

2、1。9812 是非素数,则该数不满足条件忽略。注意:部分源程序存在文件 PROG1.C 文件中。程序中已定义数组:a300,b300,已定义变量:cnt。请勿改动数据文件 IN.DAT 中的任何数据、主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序#include int a300,b300,cnt=0;void readDat();void writeDat();void jsValue();int isP(int m)int i;for(i=2;im;i+)if(m%i=0)return 0;return 1;void jsValue()vo

3、id main()int i;readDat();jsValue();writeDat();printf(“cnt=%d/n“,cnt);for(i=0;icnt;i+)printf(“b%d=%d/n”,i,bi);void readDat()FILE *fP;int i;fp=fopen(“in.dat”,“r“);for(i=0;i300;i+)fscanf(fp,“%d,”,fp=fopen(“out.dat“,“w“);fprintf(fp,“%d/n“,cnt);for(i=0;icnt;i+)fprintf(fp,“%d/n“,bi);fclose(fp);(分数:100.00)

4、三级网络技术机试-225 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知文件 IN.DAT 中存有 300 个四位数,并已调用读函数 readDat()把这些数存入数组 a 中,请编制一个函数 isValue(),其功能是:求出所有这些四位数是素数的个数 cnt,再把所有满足此条件的四位数依次存入数组 b 中,然后对数组 b 的四位数按从小到大的顺序进行排序。最后 main()函数调用写函数writeDat()把数组 b 中的数输出到 OUT.DAT 文件。例如,5591 是素数,则该数满足条件存入数组 b 中,且个数 cnt=cnt

5、1。9812 是非素数,则该数不满足条件忽略。注意:部分源程序存在文件 PROG1.C 文件中。程序中已定义数组:a300,b300,已定义变量:cnt。请勿改动数据文件 IN.DAT 中的任何数据、主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序#include int a300,b300,cnt=0;void readDat();void writeDat();void jsValue();int isP(int m)int i;for(i=2;im;i+)if(m%i=0)return 0;return 1;void jsValue()vo

6、id main()int i;readDat();jsValue();writeDat();printf(“cnt=%d/n“,cnt);for(i=0;icnt;i+)printf(“b%d=%d/n”,i,bi);void readDat()FILE *fP;int i;fp=fopen(“in.dat”,“r“);for(i=0;i300;i+)fscanf(fp,“%d,”,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 jsValue()int i,j; /*定义变量*/int temp;for(i=0;i300;i+) /*统计筛选*/if(isP(ai)bcnt+=ai;for(i=0;icnt-1;i+) /*选择法排序*/for(j=i+1;jcnt;j+)if(bibj) temp=bi;bi=bj;bj=temp;)解析:解析 本题要求统计已知数中素数的个数并对这些素数进行排序。依据题意,应依次从数组 a 中取出每一个四位数,用 isP()函数判断其是否是素数,如果是素数,那么存入数组 b 中,同时计数器变量cnt 加 1,最后对数组 b 进行用选择法进行排序。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 2943-1990 Aerospace Series Wire Thread Inserts Prevailing Torque (Self- Locking) Technical Specification Issue P 1《航空航天系列插入螺旋线主要扭矩自锁技术规范.P1版》.pdf AECMA PREN 2943-1990 Aerospace Series Wire Thread Inserts Prevailing Torque (Self- Locking) Technical Specification Issue P 1《航空航天系列插入螺旋线主要扭矩自锁技术规范.P1版》.pdf
  • AECMA PREN 2944-1990 Aerospace Series Insert Screw Thread Helical Coil Self- Locking in Corrosion Resisting Alloy (Z10CN18-09-EN2947) Unplated Issue P 1《航空航天系列插入螺旋卷螺纹自锁防腐蚀镍基镀金合金(Z1.pdf AECMA PREN 2944-1990 Aerospace Series Insert Screw Thread Helical Coil Self- Locking in Corrosion Resisting Alloy (Z10CN18-09-EN2947) Unplated Issue P 1《航空航天系列插入螺旋卷螺纹自锁防腐蚀镍基镀金合金(Z1.pdf
  • AECMA PREN 2945-1990 Aerospace Series Assembly with Self-Locking Thread Inserts Issue P 1《航空航天系列组件带自锁插入螺纹.P1版》.pdf AECMA PREN 2945-1990 Aerospace Series Assembly with Self-Locking Thread Inserts Issue P 1《航空航天系列组件带自锁插入螺纹.P1版》.pdf
  • AECMA PREN 2947-1998 Aerospace Series Steel FE-PA3004 (X10CrNi18-09) Air Melted Non Heat Treated Cold Drawn Wire a or D Less than or Equal to 2 3 mm Edition P 2《航空航天系列FE-PA3004(X10.pdf AECMA PREN 2947-1998 Aerospace Series Steel FE-PA3004 (X10CrNi18-09) Air Melted Non Heat Treated Cold Drawn Wire a or D Less than or Equal to 2 3 mm Edition P 2《航空航天系列FE-PA3004(X10.pdf
  • AECMA PREN 2948-1986 Aerospace Series Washers Tab Heat Resisting Steel Issue P 1《航空航天系列耐热钢垫圈.P1版》.pdf AECMA PREN 2948-1986 Aerospace Series Washers Tab Heat Resisting Steel Issue P 1《航空航天系列耐热钢垫圈.P1版》.pdf
  • AECMA PREN 2949-1986 Aerospace Series Washer Bent Tab Heat Resisting Steel Issue P 1《航空航天系列耐热钢垫圈.P1版》.pdf AECMA PREN 2949-1986 Aerospace Series Washer Bent Tab Heat Resisting Steel Issue P 1《航空航天系列耐热钢垫圈.P1版》.pdf
  • AECMA PREN 2950-2007 Aerospace series Test method Wrought heat resisting alloys Semi-finished products and parts Conditions for macrographic and micrographic examination Atlas of s.pdf AECMA PREN 2950-2007 Aerospace series Test method Wrought heat resisting alloys Semi-finished products and parts Conditions for macrographic and micrographic examination Atlas of s.pdf
  • AECMA PREN 2951-1997 Aerospace Series Metallic Materials Test Method Micrographic Determination of Content of Non-Metallic Inclusions Edition P 1《航空航天系列金属材料试验方法非金属夹杂含量的显微测定》.pdf AECMA PREN 2951-1997 Aerospace Series Metallic Materials Test Method Micrographic Determination of Content of Non-Metallic Inclusions Edition P 1《航空航天系列金属材料试验方法非金属夹杂含量的显微测定》.pdf
  • AECMA PREN 2952-1995 Aerospace Series Heat Resisting Alloy NI-PH2601 Solution Treated and Cold Worked Bar for Forged Fasteners D Less Than or Equal to 50 mm 1270 MPa Less Than or En.pdf AECMA PREN 2952-1995 Aerospace Series Heat Resisting Alloy NI-PH2601 Solution Treated and Cold Worked Bar for Forged Fasteners D Less Than or Equal to 50 mm 1270 MPa Less Than or En.pdf
  • 相关搜索

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

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