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

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

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

2、)的内容。试题程序; #include#include#include#define MAX 1000int inBufMAX, odd=0, even=0; double ave=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 国家三级 (网络技术)机试模拟试卷 269答案与解析 一、程序设计题 1 【正确答案】 void Compute(void) int i; for(i=0;

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

展开阅读全文
相关资源
猜你喜欢
  • ASTM A664-2014 Standard Practice for Identification of Standard Electrical Steel Grades in ASTM Specifications《美国材料试验学会规范中鉴定标准电工钢等级的标准操作规程》.pdf ASTM A664-2014 Standard Practice for Identification of Standard Electrical Steel Grades in ASTM Specifications《美国材料试验学会规范中鉴定标准电工钢等级的标准操作规程》.pdf
  • ASTM A664-2015 Standard Practice for Identification of Standard Electrical Steel Grades in ASTM Specifications《识别ASTM规范中标准电工钢级别的标准实践规程》.pdf ASTM A664-2015 Standard Practice for Identification of Standard Electrical Steel Grades in ASTM Specifications《识别ASTM规范中标准电工钢级别的标准实践规程》.pdf
  • ASTM A666-2003 Standard Specification for Annealed or Cold-Worked Austenitic Stainless Steel Sheet Strip Plate and Flat Bar《退火或冷加工的奥氏体不锈钢薄板、带材、中厚板和扁棒用标准规范》.pdf ASTM A666-2003 Standard Specification for Annealed or Cold-Worked Austenitic Stainless Steel Sheet Strip Plate and Flat Bar《退火或冷加工的奥氏体不锈钢薄板、带材、中厚板和扁棒用标准规范》.pdf
  • ASTM A666-2010 Standard Specification for Annealed or Cold-Worked Austenitic Stainless Steel Sheet Strip Plate and Flat Bar《退火或冷加工的奥氏体不锈钢薄板 带材 中厚板和扁棒的标准规范》.pdf ASTM A666-2010 Standard Specification for Annealed or Cold-Worked Austenitic Stainless Steel Sheet Strip Plate and Flat Bar《退火或冷加工的奥氏体不锈钢薄板 带材 中厚板和扁棒的标准规范》.pdf
  • ASTM A666-2015 Standard Specification for Annealed or Cold-Worked Austenitic Stainless Steel Sheet Strip Plate and Flat Bar《退火或冷加工的奥氏体不锈钢薄板 带材 厚板和扁棒材的标准规格》.pdf ASTM A666-2015 Standard Specification for Annealed or Cold-Worked Austenitic Stainless Steel Sheet Strip Plate and Flat Bar《退火或冷加工的奥氏体不锈钢薄板 带材 厚板和扁棒材的标准规格》.pdf
  • ASTM A667 A667M-1987(2003) Standard Specification for Centrifugally Cast Dual Metal (Gray and White Cast Iron) Cylinders.pdf ASTM A667 A667M-1987(2003) Standard Specification for Centrifugally Cast Dual Metal (Gray and White Cast Iron) Cylinders.pdf
  • ASTM A667 A667M-1987(2008) Standard Specification for Centrifugally Cast Dual Metal (Gray and White Cast Iron) Cylinders《离心铸造的双金属(灰口及白口铸铁)圆柱体的标准规范》.pdf ASTM A667 A667M-1987(2008) Standard Specification for Centrifugally Cast Dual Metal (Gray and White Cast Iron) Cylinders《离心铸造的双金属(灰口及白口铸铁)圆柱体的标准规范》.pdf
  • ASTM A667 A667M-1987(2012) Standard Specification for Centrifugally Cast Dual Metal (Gray and White Cast Iron) Cylinders《离心铸造的双金属(灰口及白口铸铁)圆柱体的标准规格》.pdf ASTM A667 A667M-1987(2012) Standard Specification for Centrifugally Cast Dual Metal (Gray and White Cast Iron) Cylinders《离心铸造的双金属(灰口及白口铸铁)圆柱体的标准规格》.pdf
  • ASTM A668 A668M-2004 Standard Specification for Steel Forgings Carbon and Alloy for General Industrial Use.pdf ASTM A668 A668M-2004 Standard Specification for Steel Forgings Carbon and Alloy for General Industrial Use.pdf
  • 相关搜索

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

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