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

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

1、三级网络技术机试-45 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.下列程序的功能是:计算 500800 之间素数的个数 cnt,并按所求素数的值从小到大的顷序,再计算其间隔加、减之和,即第 1 个素数-第 2 个素数十第 3 个素数-第 4 个素数+第 5 个素数的值 sum。请编写函数 countValue()实现程序的要求,最后调用函数 writeDaI()把结果 cnt 和 sum 输出到文件OUT66.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()和写函数 writeDAT()的内容。试题程序;#includ

2、estdio. hint cnt, sum;void countValue()void main()cnt=sum=0;countValue ();printf (“素数的个数=%d/n“, ont);printf (“按要求计算得值=%d/n“, sum );writeDAT ();writeDAT ()FILE *fp;fp=fopen ( “OUT66. DAT“, “w“ );fprintf (fp, “%d/n%d/n“, cnt, sum);fclose (fp);(分数:100.00)_三级网络技术机试-45 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数

3、1,分数:100.00)1.下列程序的功能是:计算 500800 之间素数的个数 cnt,并按所求素数的值从小到大的顷序,再计算其间隔加、减之和,即第 1 个素数-第 2 个素数十第 3 个素数-第 4 个素数+第 5 个素数的值 sum。请编写函数 countValue()实现程序的要求,最后调用函数 writeDaI()把结果 cnt 和 sum 输出到文件OUT66.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()和写函数 writeDAT()的内容。试题程序;#includestdio. hint cnt, sum;void countValue()void main

4、)cnt=sum=0;countValue ();printf (“素数的个数=%d/n“, ont);printf (“按要求计算得值=%d/n“, sum );writeDAT ();writeDAT ()FILE *fp;fp=fopen ( “OUT66. DAT“, “w“ );fprintf (fp, “%d/n%d/n“, cnt, sum);fclose (fp);(分数:100.00)_正确答案:(void countValue() int i,j,half,yy100;for(i=500;i=half) /*如果该数是素数,则将该数存入数组 yy 中*/ yycnt=i;

5、cnt+; /*统计素数的个数*/for (i=0, j =-1; icnt; i+) /*计算这些素数的间隔加、减之和*/ j=j*-1;sum+=j*yyi;)解析:解析本题考查的知识点如下:(1)利用循环和“%”进行素数的判断。(2)间隔加、减的实现。在本题中,首先要找出判断素数的方法。若一个数 a 依次除以从 2 到 a/2 的数所得的余数都不是 0,则这个数是素数。用此方法依次判断出从 500 到 800 区间内的素数。由题意可知,第 1,3,5个素数计算加法,第 2,4,6个素数计算减法。减去 1 个正整数就是加上负的这个正整数,所以可以将这个正整数乘以-1 进行加法。使用循环实现求和,在奇数次的循环中,每个素数乘以 1,偶数次的循环中,素数乘以-1,就可实现间隔加、减。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 1930-2012 Child use and care articles - Safety barriers - Safety requirements and test methods German version EN 1930 2011《儿童使用和保育用品 安全护栏 安全要求和试验方法 德文版本 EN 1930-2011》.pdf DIN EN 1930-2012 Child use and care articles - Safety barriers - Safety requirements and test methods German version EN 1930 2011《儿童使用和保育用品 安全护栏 安全要求和试验方法 德文版本 EN 1930-2011》.pdf
  • DIN EN 1931-2001 Flexible sheets for waterproofing - Bitumen plastic and rubber sheets for roof waterproofing - Determination of water vapour transmission properties German version.pdf DIN EN 1931-2001 Flexible sheets for waterproofing - Bitumen plastic and rubber sheets for roof waterproofing - Determination of water vapour transmission properties German version.pdf
  • DIN EN 1932-2013 External blinds and shutters - Resistance to wind loads - Method of testing and performance criteria German version EN 1932 2013《外部窗帘和百叶窗 抗风力 试验方法和性能标准 德文版本EN 1932.pdf DIN EN 1932-2013 External blinds and shutters - Resistance to wind loads - Method of testing and performance criteria German version EN 1932 2013《外部窗帘和百叶窗 抗风力 试验方法和性能标准 德文版本EN 1932.pdf
  • DIN EN 1933-1999 Exterior blinds - Resistance to load due to water accumulation - Test method German version EN 1933 1998《遮篷 积水负载强度 试验方法》.pdf DIN EN 1933-1999 Exterior blinds - Resistance to load due to water accumulation - Test method German version EN 1933 1998《遮篷 积水负载强度 试验方法》.pdf
  • DIN EN 1934-1998 Termal performance of buildings - Determination of thermal resistance by hot box method using heat flow meter - Masonry German version EN 1934 1998《建筑物热性能 热阻测量 热流计.pdf DIN EN 1934-1998 Termal performance of buildings - Determination of thermal resistance by hot box method using heat flow meter - Masonry German version EN 1934 1998《建筑物热性能 热阻测量 热流计.pdf
  • DIN EN 1935-2002 Building hardware - Single-axis hinges - Requirements and test methods German version EN 1935 2002《建筑五金件 单轴铰链 要求和试验方法》.pdf DIN EN 1935-2002 Building hardware - Single-axis hinges - Requirements and test methods German version EN 1935 2002《建筑五金件 单轴铰链 要求和试验方法》.pdf
  • DIN EN 1936-2007 Natural stone test method - Determination of real density and apparent density and of total and open porosity English version of DIN EN 1936 2007-02《天然石料检验方法 测定实际和.pdf DIN EN 1936-2007 Natural stone test method - Determination of real density and apparent density and of total and open porosity English version of DIN EN 1936 2007-02《天然石料检验方法 测定实际和.pdf
  • DIN EN 1937-1999 Test method for hydraulic setting floor smoothing and or levelling compounds - Standard mixing procedures German version EN 1937 1999《胶粘剂 液压固化地板镘光和 或整平化合物的检验方法 标准混.pdf DIN EN 1937-1999 Test method for hydraulic setting floor smoothing and or levelling compounds - Standard mixing procedures German version EN 1937 1999《胶粘剂 液压固化地板镘光和 或整平化合物的检验方法 标准混.pdf
  • DIN EN 1938-2010 Personal eye protection - Goggles for motorcycle and moped users German version EN 1938 2010《人员眼睛保护 摩托车和机动脚踏两用车驾驶员用防护镜》.pdf DIN EN 1938-2010 Personal eye protection - Goggles for motorcycle and moped users German version EN 1938 2010《人员眼睛保护 摩托车和机动脚踏两用车驾驶员用防护镜》.pdf
  • 相关搜索

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

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