【计算机类职业资格】三级信息管理技术机试-249及答案解析.doc

上传人:dealItalian200 文档编号:1320719 上传时间:2019-10-17 格式:DOC 页数:3 大小:31KB
下载 相关 举报
【计算机类职业资格】三级信息管理技术机试-249及答案解析.doc_第1页
第1页 / 共3页
【计算机类职业资格】三级信息管理技术机试-249及答案解析.doc_第2页
第2页 / 共3页
【计算机类职业资格】三级信息管理技术机试-249及答案解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、三级信息管理技术机试-249 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.请编制函数 ReadDat()实现从文件 IN84.DAT 中读取 1000 个十进制整数到数组 xx 中。请编制函数Compute()分别计算出 xx 中奇数的个数 odd、奇数的平均值 ave1、偶数的平均值 ave2 及所有奇数的方差totfc 的值。最后调用函数 WriteDat()把结果输出到 OUT84.DAT 文件中。计算方差的公式如下:(分数:100.00)_三级信息管理技术机试-249 答案解析(总分:100.00,做题时间:90 分钟)一、上机

2、题(总题数:1,分数:100.00)1.请编制函数 ReadDat()实现从文件 IN84.DAT 中读取 1000 个十进制整数到数组 xx 中。请编制函数Compute()分别计算出 xx 中奇数的个数 odd、奇数的平均值 ave1、偶数的平均值 ave2 及所有奇数的方差totfc 的值。最后调用函数 WriteDat()把结果输出到 OUT84.DAT 文件中。计算方差的公式如下:(分数:100.00)_正确答案:(int ReadDat(void)FILE * fpint i,j; /*定义计数器变量*/if(fp=fopen(“IN84.DAT“,“r“)=NULL)return

3、 1;for(i=0;i100;i + +) /*依次读取整型数据放入数组 xx 中*/for(j=0;j10;j + +)fscanf(fp,“% d,“,&xxi*10+j);fscanf(fp,“/n“);if(feof(fp)break; /*文件读取结束,则退出*/fclose(fp);return 0;void Compute(void)int i; /*定义循环控制变量*/int ttMAX; /*定义数组保存奇数*/for(i=0;i1000;i + +)if(xxi% 2!=0)odd + +; /*计算出 xx 中奇数的个数 odd*/ave1+=xxi; /*求奇数的和*

4、/ttodd-1=xxi; /*将奇数存入数组 tt 中*/elseeven + +; /*计算出 xx 中偶数的个数 even*/ave2+=xxi; /*求偶数的和*/ave1/=odd; /*求奇数的平均值*/are2/=even; /*求偶数的平均值*/for(i=0;iodd;i + +)totfc+=(tti-ave1)*(tti-ave1)/odd; /*求所有奇数的方差*/)解析:解析 在本题中,数据的存放很有规律,将数据读出存入数组 xx 时,只要控制数组下标就可以了。若文件结束,则退出循环,最后要关闭文件。用循环控制取得每一个数进行判断,若一个数除以 2 取余得0,则该数是偶数,否则为奇数。分别统计奇数和偶数的个数、总和,并且保存所有满足条件的奇数。最后由方差公式可知,这是求一些连续的数的表达式的值,所以可以使用循环求得方差。

展开阅读全文
相关资源
猜你喜欢
  • BS ISO 18535-2016 Diamond-like carbon films Determination of friction and wear characteristics of diamond-like carbon films by ball-on-disc method《类金刚石薄膜 采用球盘法测定类金刚石薄膜的摩擦和磨损特性》.pdf BS ISO 18535-2016 Diamond-like carbon films Determination of friction and wear characteristics of diamond-like carbon films by ball-on-disc method《类金刚石薄膜 采用球盘法测定类金刚石薄膜的摩擦和磨损特性》.pdf
  • BS ISO 18537-2015 Traceability of crustacean products Specifications on the information to be recorded in captured crustacean distribution chains《甲壳类动物产品的可追溯性 甲壳动物捕获分布链中已记录的信息规范》.pdf BS ISO 18537-2015 Traceability of crustacean products Specifications on the information to be recorded in captured crustacean distribution chains《甲壳类动物产品的可追溯性 甲壳动物捕获分布链中已记录的信息规范》.pdf
  • BS ISO 18538-2015 Traceability of molluscan products Specifications on the information to be recorded in farmed molluscan distribution chains《软体动物产品的可追溯性 将被记录在养殖的软体动物分销链中的信息的规格》.pdf BS ISO 18538-2015 Traceability of molluscan products Specifications on the information to be recorded in farmed molluscan distribution chains《软体动物产品的可追溯性 将被记录在养殖的软体动物分销链中的信息的规格》.pdf
  • BS ISO 18539-2015 Traceability of molluscan products Specifications on the information to be recorded in captured molluscan distribution chains《软体动物产品的可追溯性 将被记录在捕获的软体动物分销链中的信息的规格》.pdf BS ISO 18539-2015 Traceability of molluscan products Specifications on the information to be recorded in captured molluscan distribution chains《软体动物产品的可追溯性 将被记录在捕获的软体动物分销链中的信息的规格》.pdf
  • BS ISO 18549-1-2009 Metallic powders - Determination of apparent density and flow rate at elevated temperatures - Determination of apparent density at elevated temperatures《金属粉末 在高.pdf BS ISO 18549-1-2009 Metallic powders - Determination of apparent density and flow rate at elevated temperatures - Determination of apparent density at elevated temperatures《金属粉末 在高.pdf
  • BS ISO 18549-2-2009 Metallic powders - Determination of apparent density and flow rate at elevated temperatures - Determination of flow rate at elevated temperatures《金属粉末 高温条件下表观密度.pdf BS ISO 18549-2-2009 Metallic powders - Determination of apparent density and flow rate at elevated temperatures - Determination of flow rate at elevated temperatures《金属粉末 高温条件下表观密度.pdf
  • BS ISO 18550-2016 Fine ceramics (advanced ceramics advanced technical ceramics) Testing method for macroheterogeneity in microstructure《精细陶瓷 (高级陶瓷 高级工业陶瓷) 微观结构宏观异质性的试验方法》.pdf BS ISO 18550-2016 Fine ceramics (advanced ceramics advanced technical ceramics) Testing method for macroheterogeneity in microstructure《精细陶瓷 (高级陶瓷 高级工业陶瓷) 微观结构宏观异质性的试验方法》.pdf
  • BS ISO 18553-2002 Method for the assessment of the degree of pigment or carbon black dispersion in polyolefin pipes fittings and compounds《在聚烯烃管、配件和化合物中颜料或炭黑分散程度的评定方法》.pdf BS ISO 18553-2002 Method for the assessment of the degree of pigment or carbon black dispersion in polyolefin pipes fittings and compounds《在聚烯烃管、配件和化合物中颜料或炭黑分散程度的评定方法》.pdf
  • BS ISO 18554-2016 Surface chemical analysis Electron spectroscopies Procedures for identifying estimating and correcting for unintended degradation by X-rays in a material undergoi表.pdf BS ISO 18554-2016 Surface chemical analysis Electron spectroscopies Procedures for identifying estimating and correcting for unintended degradation by X-rays in a material undergoi表.pdf
  • 相关搜索

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

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