[计算机类试卷]计算机三级网络技术机试(上机操作)模拟试卷47及答案与解析.doc

上传人:deputyduring120 文档编号:505708 上传时间:2018-11-29 格式:DOC 页数:3 大小:25KB
下载 相关 举报
[计算机类试卷]计算机三级网络技术机试(上机操作)模拟试卷47及答案与解析.doc_第1页
第1页 / 共3页
[计算机类试卷]计算机三级网络技术机试(上机操作)模拟试卷47及答案与解析.doc_第2页
第2页 / 共3页
[计算机类试卷]计算机三级网络技术机试(上机操作)模拟试卷47及答案与解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、计算机三级网络技术机试(上机操作)模拟试卷 47及答案与解析 一、程序设计题 1 请编写函数 countValue(),其功能是:找出所有 100以内 (含 100)满足 I、 I+4、I+10都是素数的整数 I(I+10也是在 100以内 )的个数 count,以及这些 I之和 sum。函数 WriteData()负责把结果输出到 OUT DAT文件中。 注意:部分源程序已给出。 请勿改动主函数 main()和写函数 WriteData()的内容。 试题程序: #include int count, sum void WriteData(); void countValue() ) void

2、 main() count=sum=0; countValue(); printf(“count=- d nsum= d n”, count, sum); WriteData(); void WriteData() FILE*fp; fp=fopen(“OUT DAT”, “W”); fprintf(fp, “ d n d n”, count, sum); fclose(fp); 计算机三级网络技术机试(上机操作)模拟试卷 47答案与解析 一、程序设计题 1 【正确答案】 void countValue() int i, j, k, d3, flag; for(i=0; i=100-10; i

3、) dE0=i; d1=i+4; d2=i+10; 将三个数存入数组,以方便用循环 flag=0;将标志位清零 for(k=0; k3; k+) for(j=2; jdk; j+) 判断是否为素数 if(dk j=0) 如果一个数除了自身和 1之外还有其他余 数,则该数不是素数 flag=1;将标志置 1 break; 一旦发现不满足条件的数就退出循环 if(flag=0)如果满足条件 sum+=i; 将该数加人总和 count+;计数器加 1 ) 【试题解析】 本题主要考查素数的判断问题。 判断是否为素数:素数的定义是:若一个数除了其自身和 1再没有其他的除数,则该数就是素数。故用其定义可以很容易判断。在 2到所判断数之间的数进行扫描,若有一个除数,则该数就不是素数。 判断 3个数是不是都是素数,若有一个不是,则不符合要求,即可进行下一轮判断。

展开阅读全文
相关资源
猜你喜欢
  • BS ISO 7194-2008 en_5756  Measurement of fluid flow in closed conduits - Velocity-area methods of flow measurement in swirling or asymmetric flow conditions in circular ducts by means.pdf BS ISO 7194-2008 en_5756 Measurement of fluid flow in closed conduits - Velocity-area methods of flow measurement in swirling or asymmetric flow conditions in circular ducts by means.pdf
  • BS ISO 834-10-2014 en_5766  Fire resistance tests Elements of building construction Specific requirements to determine the contribution of applied fire protection.pdf BS ISO 834-10-2014 en_5766 Fire resistance tests Elements of building construction Specific requirements to determine the contribution of applied fire protection.pdf
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • 相关搜索

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

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