[计算机类试卷]国家三级信息管理技术机试模拟试卷82及答案与解析.doc

上传人:fuellot230 文档编号:495013 上传时间: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中,请编制一函敞 jsValue(),其功能是:求出这些 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(); jsValue

3、); writeDat(); printf(“cnt=%dn满足条件的平均值 pjz1=%7.2lfn不满足条件的平均值 pjz2=%7.2lfn“,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.2lfn%7.2lfn“,cnt ,pjz1,piz2); fclo

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

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TR 63021-2016 Rotating electrical machinery Natural graphite brush for slip-ring in wound rotor-type induction motor Application information《旋转电机 绕线式感应电动机内的滑环用天然.pdf BS PD IEC TR 63021-2016 Rotating electrical machinery Natural graphite brush for slip-ring in wound rotor-type induction motor Application information《旋转电机 绕线式感应电动机内的滑环用天然.pdf
  • BS PD IEC TR 63036-2016 Electrical interface specification for phase-cut dimmer in phase-cut dimmed lighting systems《舍相调光系统用舍相减光器的电气接口规格》.pdf BS PD IEC TR 63036-2016 Electrical interface specification for phase-cut dimmer in phase-cut dimmed lighting systems《舍相调光系统用舍相减光器的电气接口规格》.pdf
  • BS PD IEC TR 63037-2016 Electrical interface specifications for self ballasted lamps and controlgear in phase-cut dimmed lighting systems《舍相暗光系统用自镇流灯和控制设备的电气接口规格》.pdf BS PD IEC TR 63037-2016 Electrical interface specifications for self ballasted lamps and controlgear in phase-cut dimmed lighting systems《舍相暗光系统用自镇流灯和控制设备的电气接口规格》.pdf
  • BS PD IEC TR 63039-2016 Probabilistic risk analysis of technological systems Estimation of final event rate at a given initial state《技术系统的概率风险分析 评估给定初始状态下的最终事件率》.pdf BS PD IEC TR 63039-2016 Probabilistic risk analysis of technological systems Estimation of final event rate at a given initial state《技术系统的概率风险分析 评估给定初始状态下的最终事件率》.pdf
  • BS PD IEC TR 63040-2016 Guidance on clearances and creepage distances in particular for distances equal to or less than 2 mm Test results of research on influencing parame.pdf BS PD IEC TR 63040-2016 Guidance on clearances and creepage distances in particular for distances equal to or less than 2 mm Test results of research on influencing parame.pdf
  • BS PD IEC TR 63051-2017 Documentation on design automation subjects Mathematical algorithm hardware description languages for system level modeling and verification (HDLMa.pdf BS PD IEC TR 63051-2017 Documentation on design automation subjects Mathematical algorithm hardware description languages for system level modeling and verification (HDLMa.pdf
  • BS PD IEC TR 63065-2017 Guidelines for operation and maintenance of line commutated converter (LCC) HVDC converter station《线路换向换流器(LCC)HVDC换流站运行和维护指南》.pdf BS PD IEC TR 63065-2017 Guidelines for operation and maintenance of line commutated converter (LCC) HVDC converter station《线路换向换流器(LCC)HVDC换流站运行和维护指南》.pdf
  • BS PD IEC TR 63079-2017 Code of practice for hearing-loop systems (HLS)《听力回路系统操作规程》.pdf BS PD IEC TR 63079-2017 Code of practice for hearing-loop systems (HLS)《听力回路系统操作规程》.pdf
  • BS PD IEC TR 63099-1-2017 Transmitting equipment for radiocommunication Radio-over-fibre technologies for electromagnetic-field measurement Radio-over-fibre technologies f.pdf BS PD IEC TR 63099-1-2017 Transmitting equipment for radiocommunication Radio-over-fibre technologies for electromagnetic-field measurement Radio-over-fibre technologies f.pdf
  • 相关搜索

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

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