【计算机类职业资格】三级网络技术机试-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 进行用选择法进行排序。

展开阅读全文
相关资源
猜你喜欢
  • NF S31-077-1-1992 Acoustics Determination of dynamic stiffness Part 1  materials used under floating floors in dwellings 《声学 动力劲度的测定 第1部分 住宅浮隔地板下面使用的村料》.pdf NF S31-077-1-1992 Acoustics Determination of dynamic stiffness Part 1 materials used under floating floors in dwellings 《声学 动力劲度的测定 第1部分 住宅浮隔地板下面使用的村料》.pdf
  • NF S31-078-1-1989 Acoustics Statistical methods for determining and verifying stated noise emission values of machinery and equipment Part 1  general considerations and definitions.pdf NF S31-078-1-1989 Acoustics Statistical methods for determining and verifying stated noise emission values of machinery and equipment Part 1 general considerations and definitions.pdf
  • NF S31-078-2-1989 Acoustics Statistical methods for determining and verifying stated noise emission values of machinery and equipment Part 2  methods for stated values for individu.pdf NF S31-078-2-1989 Acoustics Statistical methods for determining and verifying stated noise emission values of machinery and equipment Part 2 methods for stated values for individu.pdf
  • NF S31-078-3-1989 Acoustics Statistical methods for determining and verifying stated noise emission values of machinery and equipment Part 3  simple (transition) method for stated .pdf NF S31-078-3-1989 Acoustics Statistical methods for determining and verifying stated noise emission values of machinery and equipment Part 3 simple (transition) method for stated .pdf
  • NF S31-078-4-1989 Acoustics Statistical methods for determining and verifying stated noise emission values of machinery and equipment Part 4  methods for stated values for batches .pdf NF S31-078-4-1989 Acoustics Statistical methods for determining and verifying stated noise emission values of machinery and equipment Part 4 methods for stated values for batches .pdf
  • NF S31-080-2006 Acoustics - Offices and associated areas - Acoustic performance levels and criteria by type of area 《声学 办公和相关区 区域类型的声学性能等级和标准》.pdf NF S31-080-2006 Acoustics - Offices and associated areas - Acoustic performance levels and criteria by type of area 《声学 办公和相关区 区域类型的声学性能等级和标准》.pdf
  • NF S31-085-2002 Acoustics - Characterization and measurement of road traffic noise - General measurement specifications 《声学 道路交通噪声的表征和测量 一般测量规范》.pdf NF S31-085-2002 Acoustics - Characterization and measurement of road traffic noise - General measurement specifications 《声学 道路交通噪声的表征和测量 一般测量规范》.pdf
  • NF S31-090-1995 TEST CODE FOR THE DETERMINATION OF AIRBORNE ACOUSTICAL NOISE EMITED BY HOUSEHOLD AND SIMILAR ELECTRICAL APPLIANCES PART 1  GENERAL REQUIREMENTS (EUROPEAN STANDARD E.pdf NF S31-090-1995 TEST CODE FOR THE DETERMINATION OF AIRBORNE ACOUSTICAL NOISE EMITED BY HOUSEHOLD AND SIMILAR ELECTRICAL APPLIANCES PART 1 GENERAL REQUIREMENTS (EUROPEAN STANDARD E.pdf
  • NF S31-091-1995 Test code for the determination of airborne acoustical noise emitted by household and similar electrical appliances Part 2  particular requirements for vacuum clean.pdf NF S31-091-1995 Test code for the determination of airborne acoustical noise emitted by household and similar electrical appliances Part 2 particular requirements for vacuum clean.pdf
  • 相关搜索

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

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