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

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

1、国家三级(网络技术)机试模拟试卷 82及答案与解析 一、程序设计题 1 已知数据文件 IN82.DAT中存有 300个 4位数,并已调用函数 readDat()把这些数存入数组 a中,请编制一函数 isValue(),其功能是:求出这些 4位数是素数的个数cnt,再求出所有满足此条件的 4位数的平均值 pjz1,以及所有不满足此条件的 4位数的平均值 pjz2,最后调用函数 writeDat()把结果 cnt,pjz1,pjz2,输出到 out82.dat文件中。 例如: 5591是素数,则该数满足条件,计算平均值 pjz1,且 个数 cnt=cnt+1。 9812是非素数,则该数不满足条件,

2、计算平均值 pjz2。 注意:部分源程序已给出。 程序中已定义数组: a300, b300,已定义变量: cnt, pjz1, pjz2。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序: #include stdio. h int a300, cnt=0; double pjz1=0.0, pjz2=0.0; int isP(int m) int i; for (i=2; i m; i+) if(m%i=0) return 0; return 1; void jsValue() main ( ) int i; readDat ();

3、jsValue(); writeDat (); printf (“cnt=%dn满足条件的平均值 pjz1=%7.21fn不满足条件的平均值 pjz2=%7.21fn“, cnt, pjz1, pjz2); readDat ( ) FILE *fp; int i; fp=fopen(“in82.dat“,“r“); for (i=0; i 300; i+) fscanf (fp, “%d, “, fclose (fp); writeDat () FILE *fp; int i; fp=fopen(“out82.dat“,“w“); fprintf(fp,“%dn%7.21fn%7.21fn“,

4、cnt,pjz1,pjz2); fclose(fp); 国家三级(网络技术)机试模拟试卷 82答案与解析 一、程序设计题 1 【正确答案】 void jsValue() int i; for(i=0;f 300;i+) if(isP(ai) /*如果该数为素数 */ pjz1+=ai; /*将满足条件的数求和 */ cnt+; /*统计满足条件的数的个数 */ else pjz2+=ai; /*将不满足条件的数求和 */ pjz1=pjz1/cnt; /*求满足条 件的数的平均值 */ pjz2=pjz2/(3OO-cnt); /*求不满足条件的数的平均值 */ 【试题解析】 本题考查的知识点如下: (1)循环结构的使用。 (2)判断结构的使用。 在本题中,已给出判断素数的函数 isP(),只要依次将数据带入即可。 300个数据依次存入数组中,可以使用循环实现对数据的访问。当数是素数时,求其和pjz1,并统计素数的个数。不是素数时,求和 pjz2。最后将和除以个数,即可得其平均值。

展开阅读全文
相关资源
猜你喜欢
  • BS PD ISO TR 17427-7-2015 Intelligent transport systems Cooperative ITS Privacy aspects《智能运输系统 协作ITS 隐私方面》.pdf BS PD ISO TR 17427-7-2015 Intelligent transport systems Cooperative ITS Privacy aspects《智能运输系统 协作ITS 隐私方面》.pdf
  • BS PD ISO TR 17427-8-2015 Intelligent transport systems Cooperative ITS Liability aspects《智能运输系统 协作ITS 责任方面》.pdf BS PD ISO TR 17427-8-2015 Intelligent transport systems Cooperative ITS Liability aspects《智能运输系统 协作ITS 责任方面》.pdf
  • BS PD ISO TR 17427-9-2015 Intelligent transport systems Cooperative ITS Compliance and enforcement aspects《智能运输系统 协作ITS 遵守和执行方面》.pdf BS PD ISO TR 17427-9-2015 Intelligent transport systems Cooperative ITS Compliance and enforcement aspects《智能运输系统 协作ITS 遵守和执行方面》.pdf
  • BS PD ISO TR 17465-1-2014 Intelligent transport systems Cooperative ITS Terms and definitions《智能运输系统 协同智能运输系统 术语和定义》.pdf BS PD ISO TR 17465-1-2014 Intelligent transport systems Cooperative ITS Terms and definitions《智能运输系统 协同智能运输系统 术语和定义》.pdf
  • BS PD ISO TR 17465-2-2015 Intelligent transport systems Cooperative ITS Guidelines for standards documents《智能交通系统 协同智能交通系统 标准文件指南》.pdf BS PD ISO TR 17465-2-2015 Intelligent transport systems Cooperative ITS Guidelines for standards documents《智能交通系统 协同智能交通系统 标准文件指南》.pdf
  • BS PD ISO TR 17465-3-2015 Intelligent transport systems Cooperative ITS Release procedures for standards documents《智能交通系统 协同智能交通系统 标准文件的签发规程》.pdf BS PD ISO TR 17465-3-2015 Intelligent transport systems Cooperative ITS Release procedures for standards documents《智能交通系统 协同智能交通系统 标准文件的签发规程》.pdf
  • BS PD ISO TR 17522-2015 Health informatics Provisions for health applications on mobile smart devices《健康信息学 移动 智能设备上健康应用的规定》.pdf BS PD ISO TR 17522-2015 Health informatics Provisions for health applications on mobile smart devices《健康信息学 移动 智能设备上健康应用的规定》.pdf
  • BS PD ISO TR 17529-2014 Machine tools Practical guidance and example of risk assessment on electro-discharge machines《机床 电火花机风险评估的实践指南和范例》.pdf BS PD ISO TR 17529-2014 Machine tools Practical guidance and example of risk assessment on electro-discharge machines《机床 电火花机风险评估的实践指南和范例》.pdf
  • BS PD ISO TR 17534-2-2014 Acoustics Software for the calculation of sound outdoors General recommendations for test cases and quality assurance interface《声学 户外声的计算软件 测试案例和质量保证接口的通用建议》.pdf BS PD ISO TR 17534-2-2014 Acoustics Software for the calculation of sound outdoors General recommendations for test cases and quality assurance interface《声学 户外声的计算软件 测试案例和质量保证接口的通用建议》.pdf
  • 相关搜索

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

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