[计算机类试卷]国家三级(网络技术)机试模拟试卷249及答案与解析.doc

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

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

2、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); 国家三级(网络技术)机试模拟试卷 249答案与解析 一、程序设计题 1 【正确答案】 void countValue() int i, j, k, d3, flag; for(i=0; i=100-10; i+) d0=i; dl=i+4

3、; 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判断是否为素数;素数的定义是;若一个数除了其自身和 1再没有其他的除数,则该数就是素数。故用其定义可以很容易判断。在 2到所判断数之间的数进行扫描,若有一个除数,则该数就不是素数。 2判断 3个数是不是都是素数,若有一个不是,则不符合要求,即可进行下一轮判断。

展开阅读全文
相关资源
猜你喜欢
  • ANSI ASTM D2837-2013 Standard Test Method for Obtaining Hydrostatic Design Basis for Thermoplastic Pipe Materials or Pressure Design Basis for Thermoplastic Pipe Products《获得热塑性塑料管材.pdf ANSI ASTM D2837-2013 Standard Test Method for Obtaining Hydrostatic Design Basis for Thermoplastic Pipe Materials or Pressure Design Basis for Thermoplastic Pipe Products《获得热塑性塑料管材.pdf
  • ANSI ASTM D2846 D2846M REV B-2017 Standard Specification for Chlorinated Poly(Vinyl Chloride) (CPVC) Plastic Hot- and Cold-Water Distribution Systems.pdf ANSI ASTM D2846 D2846M REV B-2017 Standard Specification for Chlorinated Poly(Vinyl Chloride) (CPVC) Plastic Hot- and Cold-Water Distribution Systems.pdf
  • ANSI ASTM D2846 D2846M-2017 Standard Specification for Chlorinated Poly(Vinyl Chloride) (CPVC) Plastic Hot- and Cold-Water Distribution Systems.pdf ANSI ASTM D2846 D2846M-2017 Standard Specification for Chlorinated Poly(Vinyl Chloride) (CPVC) Plastic Hot- and Cold-Water Distribution Systems.pdf
  • ANSI ASTM D2855-2015 Standard Practice for the Two-Step (Primer and Solvent Cement) Method of Joining Poly (Vinyl Chloride) (PVC) or Chlorinated Poly (Vinyl Chloride) (CPVC) Pipe a.pdf ANSI ASTM D2855-2015 Standard Practice for the Two-Step (Primer and Solvent Cement) Method of Joining Poly (Vinyl Chloride) (PVC) or Chlorinated Poly (Vinyl Chloride) (CPVC) Pipe a.pdf
  • ANSI ASTM D2859-2016 Standard Test Method for Ignition Characteristics of Finished Textile Floor Covering Materials.pdf ANSI ASTM D2859-2016 Standard Test Method for Ignition Characteristics of Finished Textile Floor Covering Materials.pdf
  • ANSI ASTM D2902-2000 Standard Specification for Fluoropolymer Resin Heat-Shrinkable Tubing for Electrical Insulation《含氟聚合物树脂热缩管件规范(10.02)》.pdf ANSI ASTM D2902-2000 Standard Specification for Fluoropolymer Resin Heat-Shrinkable Tubing for Electrical Insulation《含氟聚合物树脂热缩管件规范(10.02)》.pdf
  • ANSI ASTM D2903-2011 Standard Specification for Crosslinked Chlorinated Polyolefin Heat-Shrinkable Tubing for Electrical Insulation《电绝缘用交链氯化聚烯烃热缩管规范》.pdf ANSI ASTM D2903-2011 Standard Specification for Crosslinked Chlorinated Polyolefin Heat-Shrinkable Tubing for Electrical Insulation《电绝缘用交链氯化聚烯烃热缩管规范》.pdf
  • ANSI ASTM D2924-2012 Standard Test Method for External Pressure Resistance of Fiberglass (Glass-Fiber-Reinforced Thermosetting-Resin) Pipe《耐外部玻璃纤维管的压力试验》.pdf ANSI ASTM D2924-2012 Standard Test Method for External Pressure Resistance of Fiberglass (Glass-Fiber-Reinforced Thermosetting-Resin) Pipe《耐外部玻璃纤维管的压力试验》.pdf
  • ANSI ASTM D2925-2014 Standard Test Method for Beam Deflection of Fiberglass (Glass-Fiber-Reinforced Thermosetting Resin) Pipe Under Full Bore Flow.pdf ANSI ASTM D2925-2014 Standard Test Method for Beam Deflection of Fiberglass (Glass-Fiber-Reinforced Thermosetting Resin) Pipe Under Full Bore Flow.pdf
  • 相关搜索

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

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