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

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

1、三级网络技术机试-133 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.下列程序的功能是:找出所有 100以内(含 100)满足 I,I+4,I+10 都是素数的整数 I(1+10也是在 100以内)的个数 cnt,以及这些 I之和 sum。请编制函数 countValue()实现程序要求,最后调用函数writeDAT()把结果 cnt和 sum输出到文件 out64.dat中(数值 1不是素数)。注意:部分源程序已给出。请勿改动主函数 main()和输出数据函数 writeDAT()的内容。试题程序:#includestdio. hin

2、t cnt, sum;int isPrime(int number)int i, tag=l;if (number=l)return 0;for(i=2;tag i+)if(number%i=0) tag=0;return tag;void countValue ()void maincnt=sum=O;countValue ();printf (“满足条件的整数的个数=%d/n“, cnt);printf (“满足条件的整数的个数=%d/n“, sum);writeDAT ();writeDAT ( )FILE *fp;fp=fopen (“out64. dat“, “w“);fprintf

3、 ( fp, “%d/n%d/n“, cnt, sum);fclose (fp);(分数:100.00)_三级网络技术机试-133 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.下列程序的功能是:找出所有 100以内(含 100)满足 I,I+4,I+10 都是素数的整数 I(1+10也是在 100以内)的个数 cnt,以及这些 I之和 sum。请编制函数 countValue()实现程序要求,最后调用函数writeDAT()把结果 cnt和 sum输出到文件 out64.dat中(数值 1不是素数)。注意:部分源程序已给出。请勿改动主函数

4、 main()和输出数据函数 writeDAT()的内容。试题程序:#includestdio. hint cnt, sum;int isPrime(int number)int i, tag=l;if (number=l)return 0;for(i=2;tag i+)if(number%i=0) tag=0;return tag;void countValue ()void maincnt=sum=O;countValue ();printf (“满足条件的整数的个数=%d/n“, cnt);printf (“满足条件的整数的个数=%d/n“, sum);writeDAT ();write

5、DAT ( )FILE *fp;fp=fopen (“out64. dat“, “w“);fprintf ( fp, “%d/n%d/n“, cnt, sum);fclose (fp);(分数:100.00)_正确答案:(void countValue()int i,count=O,xx30;cnt=O;sum=O;for (i=2; i90; i+) /*找数的范围为 100以内*/if (isPrime (i) /*如果该数为素数,则将它存入数组 xx中,并统计个数*/xx count =i;count+;for (i=O; icount; i+) /*如果数组 xx中的素数加 4各加 10得到的数仍为素数*/if (isPrime (xx i +4) /*将满足条件的数组 xx中的数求和*/)解析:解析本题考查的知识点如下:(1)循环结构与判断结构的嵌套使用。(2)判断结构中多个条件的布尔运算。题中要求判断在 100以内,i,i+4,i+10 都是素数的个数。因为 i+10也必须在 100以内,1 不是素数,我们可以从 2开始判断到 89即可(90 是偶数,明显不是素数)。可以先找出 2到 89之间素数的个数,再判断这些素数加 4和加 10后是否还是素数。加 4是素数与加 10是素数必须同时满足,所以两个条件间用“与”运算。

展开阅读全文
相关资源
猜你喜欢
  • BS 6397-1983 Specification for scales and sizes for plotting frequency characteristics and polar diagrams《绘制频率特性和极坐标图用标度和尺寸规范》.pdf BS 6397-1983 Specification for scales and sizes for plotting frequency characteristics and polar diagrams《绘制频率特性和极坐标图用标度和尺寸规范》.pdf
  • BS 6398-1983 Specification for bitumen damp-proof courses for masonry《砖石砌筑用沥青铺防潮层规范》.pdf BS 6398-1983 Specification for bitumen damp-proof courses for masonry《砖石砌筑用沥青铺防潮层规范》.pdf
  • BS 64-1992 Specification for normal and high strength steel bolts and nuts for railway rail fishplates《铁路鱼尾板用的标准和高强度钢螺栓和螺母规范》.pdf BS 64-1992 Specification for normal and high strength steel bolts and nuts for railway rail fishplates《铁路鱼尾板用的标准和高强度钢螺栓和螺母规范》.pdf
  • BS 6400-2-2006 Specification for installation exchange relocation and removal of gas meters with a maximum capacity not exceeding 6 m3 h - Medium pressure (2nd family gases)《最大容量不超.pdf BS 6400-2-2006 Specification for installation exchange relocation and removal of gas meters with a maximum capacity not exceeding 6 m3 h - Medium pressure (2nd family gases)《最大容量不超.pdf
  • BS 6400-3-2007 Specification for ninstallation exchange nrelocation and removal nof gas meters with a nmaximum capacity not nexceeding 6 m3 h – nPart 3 Low and medium pressure n(3r.pdf BS 6400-3-2007 Specification for ninstallation exchange nrelocation and removal nof gas meters with a nmaximum capacity not nexceeding 6 m3 h – nPart 3 Low and medium pressure n(3r.pdf
  • BS 6404-12-1993 Magnetic materials - Guide to methods of assessment of temperature capability of interlaminar insulation coatings《磁性材料 第12部分 层间隔热涂层保温性能的评定方法指南》.pdf BS 6404-12-1993 Magnetic materials - Guide to methods of assessment of temperature capability of interlaminar insulation coatings《磁性材料 第12部分 层间隔热涂层保温性能的评定方法指南》.pdf
  • BS 6404-20-1996 Magnetic materials - Resistance and temperature classification of insulation coatings《磁性材料 第20部分 绝缘涂层的电阻和温度分类》.pdf BS 6404-20-1996 Magnetic materials - Resistance and temperature classification of insulation coatings《磁性材料 第20部分 绝缘涂层的电阻和温度分类》.pdf
  • BS 6405-1984 Specification for non-calibrated short link steel chain (grade 30) for general engineering purposes class 1 and 2《一般工程用非校准的短节钢链(品级30)规范 1类与2类》.pdf BS 6405-1984 Specification for non-calibrated short link steel chain (grade 30) for general engineering purposes class 1 and 2《一般工程用非校准的短节钢链(品级30)规范 1类与2类》.pdf
  • BS 6407-1-1983 Cage pallets for retail use - Specification for collapsible cage pallets rated at 300 kg《零售用柜式托盘 第1部分 300Kg承载力的可拆叠的柜式托盘规范》.pdf BS 6407-1-1983 Cage pallets for retail use - Specification for collapsible cage pallets rated at 300 kg《零售用柜式托盘 第1部分 300Kg承载力的可拆叠的柜式托盘规范》.pdf
  • 相关搜索

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

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