【计算机类职业资格】全国计算机等级考试三级网络技术机试真题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 的方差,即得到的奇数的方差。

展开阅读全文
相关资源
猜你喜欢
  • BS ISO 16656-2016 Hydraulic fluid power Single rod short-stroke cylinders with bores from 32 mm to 100 mm for use at 10 MPa (100 bar) Mounting dimensions《液压传动 10MPa(100 bar)下使用的缸径在.pdf BS ISO 16656-2016 Hydraulic fluid power Single rod short-stroke cylinders with bores from 32 mm to 100 mm for use at 10 MPa (100 bar) Mounting dimensions《液压传动 10MPa(100 bar)下使用的缸径在.pdf
  • BS ISO 16657-2006 Sensory analysis - Apparatus - Olive oil tasting glass《感官分析 器具 橄榄油品尝用玻璃杯》.pdf BS ISO 16657-2006 Sensory analysis - Apparatus - Olive oil tasting glass《感官分析 器具 橄榄油品尝用玻璃杯》.pdf
  • BS ISO 16678-2014 Guidelines for interoperable object identification and related authentication systems to deter counterfeiting and illicit trade《遏制伪造和非法贸易用可互操作的对象标识和相关认证系统指南》.pdf BS ISO 16678-2014 Guidelines for interoperable object identification and related authentication systems to deter counterfeiting and illicit trade《遏制伪造和非法贸易用可互操作的对象标识和相关认证系统指南》.pdf
  • BS ISO 16679-2015 Space systems Relative motion analysis elements after LV SC separation《空间系统 LV SC分离后的相对涌动分析元素》.pdf BS ISO 16679-2015 Space systems Relative motion analysis elements after LV SC separation《空间系统 LV SC分离后的相对涌动分析元素》.pdf
  • BS ISO 16682-2015 Aerospace series Terminology for clamping devices《航空航天系列 夹持装置术语》.pdf BS ISO 16682-2015 Aerospace series Terminology for clamping devices《航空航天系列 夹持装置术语》.pdf
  • BS ISO 16684-1-2012 Graphic technology Extensible metadata platform (XMP) specification Data model serialization and core properties《图形技术 可扩展元数据平台(XMP)规范 数据模型 序列化和核心属性》.pdf BS ISO 16684-1-2012 Graphic technology Extensible metadata platform (XMP) specification Data model serialization and core properties《图形技术 可扩展元数据平台(XMP)规范 数据模型 序列化和核心属性》.pdf
  • BS ISO 16684-2-2014 Graphic technology Extensible metadata platform (XMP) Description of XMP schemas using RELAX NG《印刷技术 可扩展元数据平台 (XMP) 使用RELAX NG描述可扩展元数据平台架构》.pdf BS ISO 16684-2-2014 Graphic technology Extensible metadata platform (XMP) Description of XMP schemas using RELAX NG《印刷技术 可扩展元数据平台 (XMP) 使用RELAX NG描述可扩展元数据平台架构》.pdf
  • BS ISO 16691-2014 Space systems Thermal control coatings for spacecraft General requirements《空间系统 航天器的热控涂层 一般要求》.pdf BS ISO 16691-2014 Space systems Thermal control coatings for spacecraft General requirements《空间系统 航天器的热控涂层 一般要求》.pdf
  • BS ISO 16694-2015 Space systems The measured parameters at firing bench and flight tests of liquid rocket engines《航天系统 液体火箭发动机点火工作台和飞行试验的测量参数》.pdf BS ISO 16694-2015 Space systems The measured parameters at firing bench and flight tests of liquid rocket engines《航天系统 液体火箭发动机点火工作台和飞行试验的测量参数》.pdf
  • 相关搜索

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

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