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

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

1、国家三级(网络技术)机试模拟试卷 255及答案与解析 一、程序设计题 1 函数 ReadData()负责从文件 IN DAT中读取 1000个十进制整数到数组 inBuf中。请编制函数 Compute()分别计算出 inBuf中偶数的个数 even、奇数的平均值avel、偶数的平均值 ave2及所有偶数的方差 tot_v的值。函数 WriteData()负责把结果输出到 OUT DAT文件中。计算方差的公式如下;设 N为偶数的个数, inBufi为偶数, ave2为偶数的平均值。原始数的存放格式是;每行存放 10个数,并 用逗号隔开 (每个数均大于 0且小于等于 2000)。注意;部分源程序已

2、给出。请勿改动主函数 main()、读函数 ReadData()和写函数 WriteData()的内容。试题程序;#include#include#include#define MAX 1000int inBufMAX, odd=0, even=0; double ave1=0 0, ave2=0 0, tot_v=0 0; void WriteData(void); int ReadData(void) FILE*fp; int i, j; if(fp=fopen(“IN DAT“, “r“)=NULL) return 1; for(i=0; i 国家三级(网络技术)机试模拟试卷 255答案

3、与解析 一、程序设计题 1 【正确答案】 void Compute(void) int i, j; for(i=0; iMAX; i+) if(inBufi 2=0)偶数的情况 even+; 偶数计数器加 1 ave2=(ave2*(even-1)+inBufi) even; *求偶数的平均值, ave2*(even-1)得出的是前 even-1个的总和 * else奇数的情况 odd+; 奇数计数器加 1 avel=(avel*(odd-1)+inBufi) odd; *求奇数的平均值, avel*(odd-1)表示的是前 odd-1个的总和 * for(i=0; iMAX; i+) if(inBufi 2=0)tot_v+=(inBufi-ave2)*(inBufi-ave2) even; *按照公式计算方差 * 【试题解析】 本题主要考查平均值和方差的计算问题。 1求平均值;由于本题中的数据量比较大,若采用先将各个值加起来再除以总个数来取平均的话,变量不能存储那么大的数据而导致溢出。本题的程序采用的方法是; N个数的平均值=前 (N-1)个数的平均值 *(N-1)+第 N个数 N,采用这种递推的方法就避免了将大的数据存入变量中而产生溢出。 2求方差;按照所给公式,将数 值代入计算即可。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 4560-2000 Aerospace Series Pipe Coupling 37 Degree Spherical Up to 21 000 kPa Inch Series Technical Specification Edition P 1《航空航天系列.导管接头37度球形直到21 000 kPa英尺系列技术规范.P1版》.pdf AECMA PREN 4560-2000 Aerospace Series Pipe Coupling 37 Degree Spherical Up to 21 000 kPa Inch Series Technical Specification Edition P 1《航空航天系列.导管接头37度球形直到21 000 kPa英尺系列技术规范.P1版》.pdf
  • AECMA PREN 4561-2000 Aerospace Series Pipe Coupling Welded in Heat Resisting Steel Elbow 90 Degree Inch Series Edition P 1《航空航天系列.导管接头焊缝耐热钢90度英尺系列.P1版》.pdf AECMA PREN 4561-2000 Aerospace Series Pipe Coupling Welded in Heat Resisting Steel Elbow 90 Degree Inch Series Edition P 1《航空航天系列.导管接头焊缝耐热钢90度英尺系列.P1版》.pdf
  • AECMA PREN 4562-2000 Aerospace Series Pipe Coupling Welded in Heat Resisting Steel Reductors Inch Series Edition P 1《航空航天系列.导管接头焊缝耐热钢减压器英尺系列.P1版》.pdf AECMA PREN 4562-2000 Aerospace Series Pipe Coupling Welded in Heat Resisting Steel Reductors Inch Series Edition P 1《航空航天系列.导管接头焊缝耐热钢减压器英尺系列.P1版》.pdf
  • AECMA PREN 4563-2000 Aerospace Series Pipe Coupling Welded in Heat Resisting Steel Tees Inch Series Edition P 1《航空航天系列.导管接头焊缝耐热钢球座英尺系列.P1版》.pdf AECMA PREN 4563-2000 Aerospace Series Pipe Coupling Welded in Heat Resisting Steel Tees Inch Series Edition P 1《航空航天系列.导管接头焊缝耐热钢球座英尺系列.P1版》.pdf
  • AECMA PREN 4566-1999 Aerospace Series Heat Resisting Alloy CO-PH4101 (CoCr20W15Ni) Vacuum Melted Solution Treated Forgings De Less Than or Equal to 100 mm Edition P1《航空航天系列.抗热合金CO-.pdf AECMA PREN 4566-1999 Aerospace Series Heat Resisting Alloy CO-PH4101 (CoCr20W15Ni) Vacuum Melted Solution Treated Forgings De Less Than or Equal to 100 mm Edition P1《航空航天系列.抗热合金CO-.pdf
  • AECMA PREN 4567-1999 Aerospace Series Heat Resisting Alloy CO-PH4101 (CoCr20W15Ni) Vacuum Melted solution Treated Bar and Section a or D Less Than or Equal to 100 mm Edition P1《航空航.pdf AECMA PREN 4567-1999 Aerospace Series Heat Resisting Alloy CO-PH4101 (CoCr20W15Ni) Vacuum Melted solution Treated Bar and Section a or D Less Than or Equal to 100 mm Edition P1《航空航.pdf
  • AECMA PREN 4568-1999 Aerospace Series Heat Resisting Alloy CO-PH4101 (CoCr20W15Ni) Vacuum Melted Solution Treated Sheet and Strip a Less Than or Equal to 6 mm Edition P1《航空航天系列.抗热合.pdf AECMA PREN 4568-1999 Aerospace Series Heat Resisting Alloy CO-PH4101 (CoCr20W15Ni) Vacuum Melted Solution Treated Sheet and Strip a Less Than or Equal to 6 mm Edition P1《航空航天系列.抗热合.pdf
  • AECMA PREN 4569-1999 Aerospace Series Heat Resisting Alloy CO-PH4101 (CoCr20W15Ni) Vacuum Melted Solution Treated Wire D Less Than or Equal to 4 mm Edition P1《航空航天系列.抗热合金CO-PH4101(.pdf AECMA PREN 4569-1999 Aerospace Series Heat Resisting Alloy CO-PH4101 (CoCr20W15Ni) Vacuum Melted Solution Treated Wire D Less Than or Equal to 4 mm Edition P1《航空航天系列.抗热合金CO-PH4101(.pdf
  • AECMA PREN 4570-1999 Aerospace Series Heat Resisting Alloy FE-PA4901 (X12CrNiCoMoW21-20) Solution Treated Forgings De Less Than or Equal to 100 mm Edition P1《航空航天系列.抗热合金FE-PA4901(X.pdf AECMA PREN 4570-1999 Aerospace Series Heat Resisting Alloy FE-PA4901 (X12CrNiCoMoW21-20) Solution Treated Forgings De Less Than or Equal to 100 mm Edition P1《航空航天系列.抗热合金FE-PA4901(X.pdf
  • 相关搜索

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

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