【计算机类职业资格】全国计算机等级考试三级网络技术机试真题2009年3月及答案解析.doc

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

1、全国计算机等级考试三级网络技术机试真题 2009 年 3 月及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.请编制函数 ReadDat(),以实现从文件 IN.DAT 中读取 1000 个十进制整数到数组 xx 中。请编制函数Compute(),以分别计算出数组 xx 中奇数的个数 odd,奇数的平均值 ave1,偶数的平均值 ave2 及所有奇数的方差 totfc,最后调用函数 WriteDat(),把结果输出到文件 OUT.DAT 中。计算方差的公式如下:(分数:100.00)_全国计算机等级考试三级网络技术机试真题 2009 年 3

2、月答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.请编制函数 ReadDat(),以实现从文件 IN.DAT 中读取 1000 个十进制整数到数组 xx 中。请编制函数Compute(),以分别计算出数组 xx 中奇数的个数 odd,奇数的平均值 ave1,偶数的平均值 ave2 及所有奇数的方差 totfc,最后调用函数 WriteDat(),把结果输出到文件 OUT.DAT 中。计算方差的公式如下:(分数:100.00)_正确答案:(int ReadDat(void)FILE *fp;int i,j;if(fp=fopen(“iN.DAT

3、r“)=NULL) return 1;for(i=0; ii00; i+)for(j=0; j10; j+)fscanf(fp,“%d,“,fscanf(fp,“/n“);if(feof(fp)break;fclose(fp);return 0;void Compute(void)int i,aaMAX;for(i=0; i1000; i+)if(xxi%2) /*若 xxi是奇数*/odd+; /*奇数计数值增加 1*/ave1+=xxi; /*将 xxi累加到 ave1 中*/aaodd-1=xxi; /*将 xxi顺序放入临时数组 aa 中*/else /*若 xxi是偶数*/ev

4、en+; /*偶数计数值增加 1*/ave2+=xxi; /*将 xxi累加到 ave2 中*/ave1/=odd; /*求奇数的平均值*/ave2/=even; /*求偶数的平均值*/for(i=0; iodd; i+) /*求方差*/totfc+=(aai-ave1)*(aai-ave1)/odd;)解析:解析本题主要考查的是方差的问题,同时考查考生对读入/输出数据的函数的掌握情况。解答本题要注意读入函数的格式,输入符后面一定要加上逗号,因为文件 IN.DAT 里面的数据是用逗号隔开的。对于将 100 行 10 列的二维数组中的数据读入 xx 一维数组时,其下标变为“i*10+j”。函数 feof()用来判断是否已经到达文件的末尾。函数 Compute()首先使用 for 循环遍历数组 xx,遇到奇数 odd 增加 1,并将该数累加到 ave1中且将此数存入临时数组 aa 中,遇到偶数 even 增加 1,并且将该数累加到 ave2中。遍历完以后,分别求出奇数和偶数的平均值。根据方差公式,使用 for 循环求出数组 aa 的方差,即得到的奇数的方差。

展开阅读全文
相关资源
猜你喜欢
  • CB T 4390 4-2013 Methods for chemical analysis of high manganese aluminum bronze for propeller Part4 Determination of nickel content《螺旋桨用高锰铝青铜化学分析方法 第4部分 镍量的测定》.pdf CB T 4390 4-2013 Methods for chemical analysis of high manganese aluminum bronze for propeller Part4 Determination of nickel content《螺旋桨用高锰铝青铜化学分析方法 第4部分 镍量的测定》.pdf
  • CB T 4390 5-2013 Methods for chemical analysis of high manganese aluminum bronze for propeller Part5 Determination of silicon content《螺旋桨用高锰铝青铜化学分析方法 第5部分 硅量的测定.pdf CB T 4390 5-2013 Methods for chemical analysis of high manganese aluminum bronze for propeller Part5 Determination of silicon content《螺旋桨用高锰铝青铜化学分析方法 第5部分 硅量的测定.pdf
  • CB T 4390 6-2013 Methods for chemical analysis of high manganese aluminum bronze for propeller Part6 Determination of lead content《螺旋桨用高锰铝青铜化学分析方法 第6部分 铅量的测定》.pdf CB T 4390 6-2013 Methods for chemical analysis of high manganese aluminum bronze for propeller Part6 Determination of lead content《螺旋桨用高锰铝青铜化学分析方法 第6部分 铅量的测定》.pdf
  • CB T 4390 7-2013 Methods for chemical analysis of high manganese aluminum bronze for propeller Part7 Determination of carbon content《螺旋桨用高锰铝青铜化学分析方法 第7部分 碳量的测定》.pdf CB T 4390 7-2013 Methods for chemical analysis of high manganese aluminum bronze for propeller Part7 Determination of carbon content《螺旋桨用高锰铝青铜化学分析方法 第7部分 碳量的测定》.pdf
  • CB T 4390 8-2013 Methods for chemical analysis of high manganese aluminum bronze for propeller Part8 Determination of zinc content《螺旋桨用高锰铝青铜化学分析方法 第8部分 锌量的测定》.pdf CB T 4390 8-2013 Methods for chemical analysis of high manganese aluminum bronze for propeller Part8 Determination of zinc content《螺旋桨用高锰铝青铜化学分析方法 第8部分 锌量的测定》.pdf
  • CB T 4390 9-2013 Methods for chemical analysis of high manganese aluminum bronze for propeller Part9 The inductively coupled plasma atomic emission spectrometri.pdf CB T 4390 9-2013 Methods for chemical analysis of high manganese aluminum bronze for propeller Part9 The inductively coupled plasma atomic emission spectrometri.pdf
  • CB T 4444-2017 Marine mushroom ventilators《船用菌形通风筒》.pdf CB T 4444-2017 Marine mushroom ventilators《船用菌形通风筒》.pdf
  • CB T 4447-2017 Copper penetrating pieces《铜通舱管件》.pdf CB T 4447-2017 Copper penetrating pieces《铜通舱管件》.pdf
  • CB T 4448-2017 Constant tension controlled valve group for hydraulic winch on ships《船用液压绞车恒张力控制阀组》.pdf CB T 4448-2017 Constant tension controlled valve group for hydraulic winch on ships《船用液压绞车恒张力控制阀组》.pdf
  • 相关搜索

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

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