【计算机类职业资格】三级数据库技术机试-290及答案解析.doc

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

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

2、数:1,分数:100.00)1.函数 ReadDat()实现从文件 IN47DAT 中读取 1000 个十进制整数到数组 xx 中。请编制函数 Compute()分别计算出 xx 中偶数的个数 even、奇数的平均值 avel、偶数的平均值 ave2 及所有偶数的方差 totfc 的值,最后调用函数 WriteDat()把结果输出到 OUT47DAT 文件中。计算方差的公式如下:(分数:100.00)_正确答案:(void Compute(void)int i,yyMAX;for(i=0;i1000;i+)if(xxi%2 !=0)odd+; /*统计奇数的个数*/ave1+=xxi; /*求

3、奇数的总和*/elseeven+; /*统计偶数的个数*/ave2+=xxi; /*求偶数的总和*/yyeven-1=xxi; /*将偶数存入数组 yy 中*/ave1/=odd; /*求奇数的平均数*/ave2/=even; /*求偶数的平均数*/for(i=0;ieven;i+) /*求所有偶数的方差*/totfc+=(yyi-ave2)*(yyi-ave2)/even;)解析:解析 本题考查的知识点如下:(1)从文件中读取数据。(2)奇偶数的判断和方差的求法。在 C 语言中,有一结构体类型 FILE,其中包含文件的一些属性信息。可定义指针指向该结构体,这个指针称为文件指针。要从文件中读取数据,首先要判断该文件是否能以“读”的方式打开。若能打开,使用函数 int fscanf(FILE*fp,char*format,args)从 fP 所指向的文件中依次读取数据。在本题中,数据的存放很有规律,将数据读出存入数组 xx 时,只要控制数组下标就可以了。若文件结束,则退出读取循环。最后要关闭文件。若一个数除以 2 取余得 0,则该数是偶数,否则为奇数。由方差公式可知,这是求一些连续的数的表达式的值,所以可以使用循环求得方差。

展开阅读全文
相关资源
猜你喜欢
  • BS ISO 6489-2-2002 Agricultural vehicles - Mechanical connections between towed and towing vehicles - Specifications for clevis coupling 40《农用车辆 被牵引和牵引车辆间的机械连接装置 第2部分 40号 U型钩接头的规范》.pdf BS ISO 6489-2-2002 Agricultural vehicles - Mechanical connections between towed and towing vehicles - Specifications for clevis coupling 40《农用车辆 被牵引和牵引车辆间的机械连接装置 第2部分 40号 U型钩接头的规范》.pdf
  • BS ISO 6489-3-2004 Agricultural vehicles - Mechanical connections between towed and towing vehicles - Tractor drawbar《农用车辆 被牵引和牵引车之间的机械连接装置 拖拉机牵引杆》.pdf BS ISO 6489-3-2004 Agricultural vehicles - Mechanical connections between towed and towing vehicles - Tractor drawbar《农用车辆 被牵引和牵引车之间的机械连接装置 拖拉机牵引杆》.pdf
  • BS ISO 6489-4-2007 Agricultural vehicles - Mechanical connections between towed and towing vehicles - Dimensions of piton-type coupling《农用车辆 被牵引与牵引车之间的机械连接装置 测定楔式耦合尺寸》.pdf BS ISO 6489-4-2007 Agricultural vehicles - Mechanical connections between towed and towing vehicles - Dimensions of piton-type coupling《农用车辆 被牵引与牵引车之间的机械连接装置 测定楔式耦合尺寸》.pdf
  • BS ISO 6489-5-2011 Agricultural vehicles Mechanical connections between towed and towing vehicles Specifications for non-swivel clevis couplings《农用车辆 挂车和牵引车之间的机械连接 非旋转U形钩联结器的规范》.pdf BS ISO 6489-5-2011 Agricultural vehicles Mechanical connections between towed and towing vehicles Specifications for non-swivel clevis couplings《农用车辆 挂车和牵引车之间的机械连接 非旋转U形钩联结器的规范》.pdf
  • BS ISO 6495-1-2015 Animal feeding stuffs Determination of water-soluble chlorides content Titrimetric method《动物饲料 水溶性氯化物含量的测定 滴定法》.pdf BS ISO 6495-1-2015 Animal feeding stuffs Determination of water-soluble chlorides content Titrimetric method《动物饲料 水溶性氯化物含量的测定 滴定法》.pdf
  • BS ISO 6502-2016 Rubber Guide to the use of curemeters《橡胶 硫化计的使用指南》.pdf BS ISO 6502-2016 Rubber Guide to the use of curemeters《橡胶 硫化计的使用指南》.pdf
  • BS ISO 6505-2015 Rubber vulcanized or thermoplastic Determination of tendency to adhere to and corrode metals《硫化或热塑性橡胶 对金属粘合和腐蚀趋势的测定》.pdf BS ISO 6505-2015 Rubber vulcanized or thermoplastic Determination of tendency to adhere to and corrode metals《硫化或热塑性橡胶 对金属粘合和腐蚀趋势的测定》.pdf
  • BS ISO 6517-2013 Air cargo Certified lower deck containers Design and testing《空运货物 被认证的下甲板集装箱 设计和测试》.pdf BS ISO 6517-2013 Air cargo Certified lower deck containers Design and testing《空运货物 被认证的下甲板集装箱 设计和测试》.pdf
  • BS ISO 6518-1-2002 Road vehicles - Ignition systems - Vocabulary《道路车辆 点火系统 词汇》.pdf BS ISO 6518-1-2002 Road vehicles - Ignition systems - Vocabulary《道路车辆 点火系统 词汇》.pdf
  • 相关搜索

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

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