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

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

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

2、题(总题数:1,分数:100.00)1.函数 ReadDat()实现从文件 in.dat中读取 1000个十进制整数到数组 xx中,请编制函数 Compute()分别计算出 xx中数值为偶数的个数 even,所有数值为奇数的平均值 ave1,偶数的平均值 ave2以及所有偶数的方差 totfc的值,最后调用函数 WriteDat()把结果输出到 out.dat文件中。 计算方差的公式如下: (分数:100.00)_正确答案:()解析:int i, odd=0; /*循环变量 i从 0开始,每次增 1,直到其值小于 MAX,对数组 xx中的每个元素的奇偶性进行判断,如果是奇数,变量 odd加 1

3、同时把这个元素累加到变量 ave1,否则,变量 even加 1,同时把这个元素累加到变量 are2*/ for(i=0; iMAX; i+) if(xxi%2)/如果 xxi是奇数 odd+; /变量 odd加 1 avel+=xxi; /把 xxi累加到变量 ave1 else even+; /变量 even加 1 ave2+=xxi; /把 xxi累加到变量 ave2 ave1/=1.0*odd; /奇数的和 ave1除以奇数的个数 odd,得到所有奇数的平均值赋给 ave1 ave2/=1.0*even; /偶数的和 ave2除以偶数的个数 even,得到所有偶数的平均值赋给 are2

4、 /*根据方差的计算公式计算所有偶数的方差*/ for(i=0;iMAX;i+) if(xxi%2=0) /如果 xxi是偶数 totfc+=(xxi-ave2)*(xxi-are2); /把(xxi-are2)的平方累加到变量 totfc totfc/=1.0*even; /变量 totfc除以偶数的个数 even,得到所有偶数的方差 解析 读取 1000个数,奇数个数及平均值,偶数个数、平均值及方差。 定义循环变量 i、表示奇数个数的变量 odd并设置其值为 0。 采用 for循环语句,对数组 xx中每个数组元素 xxi对 2求余数,如果余数为 1,则说明数组元素xxi的值为奇数,则变量

5、odd的值加 1,并把数组元素 xxi的值累加到变量 ave1,否则,说明数组元数 xxi的值为偶数,则变量 even的值加 1,并把数组元素 xxi的值累加到变量 ave2。 退出 for循环语句后,用变量 ave1除以奇数的个数 odd,得到所有奇数的平均值赋给 ave1,用变量ave2除以偶数的个数 even,得到所有偶数的平均值赋给 ave2。 利用 for循环语句,对数组 xx中每个数组元素 xxi对 2求余数,如果余数等于 0,则说明数组元素xxi的值为偶数,这时把表达式 xxi-ave2的平方值累加到变量 totfc。退出循环后,用变量 totfc的值除以偶数的个数 even,得到所有偶数的方差赋给变量 totfc。

展开阅读全文
相关资源
猜你喜欢
  • BS EN 13580-2002 Products and systems for the protection and repair of concrete structures - Test methods - Water absorption and resistance to alkali for hydrophobic impregnations《.pdf BS EN 13580-2002 Products and systems for the protection and repair of concrete structures - Test methods - Water absorption and resistance to alkali for hydrophobic impregnations《.pdf
  • BS EN 13581-2002 Products and systems for the protection and repair of concrete structures - Test methods - Determination of loss of mass of hydrophobic impregnated concrete after .pdf BS EN 13581-2002 Products and systems for the protection and repair of concrete structures - Test methods - Determination of loss of mass of hydrophobic impregnated concrete after .pdf
  • BS EN 13583-2012 Flexible sheets for waterproofing Bitumen plastic and rubber sheets for roof waterproofing Determination of hail resistance《防水柔性板 屋顶防水用沥青 塑料和橡胶薄板 防冰雹性的测定》.pdf BS EN 13583-2012 Flexible sheets for waterproofing Bitumen plastic and rubber sheets for roof waterproofing Determination of hail resistance《防水柔性板 屋顶防水用沥青 塑料和橡胶薄板 防冰雹性的测定》.pdf
  • BS EN 13584-2003 Products and systems for the protection and repair of concrete structures - Test methods - Determination of creep in compression for repair products《混凝土结构的保护和维修用产品.pdf BS EN 13584-2003 Products and systems for the protection and repair of concrete structures - Test methods - Determination of creep in compression for repair products《混凝土结构的保护和维修用产品.pdf
  • BS EN 13585-2002 Foodstuffs - Determination of fumonisins B1 and B2 in maize - HPLC method with solid phase extraction clean-up《食品 玉米中fumonisins B1和B2的含量测定 固相萃取清除HPLC测定法》.pdf BS EN 13585-2002 Foodstuffs - Determination of fumonisins B1 and B2 in maize - HPLC method with solid phase extraction clean-up《食品 玉米中fumonisins B1和B2的含量测定 固相萃取清除HPLC测定法》.pdf
  • BS EN 13586-2004+A1-2008 Cranes — Access《起重机 通路》.pdf BS EN 13586-2004+A1-2008 Cranes — Access《起重机 通路》.pdf
  • BS EN 13589-2008 Bitumen and bituminous binders - Determination of the tensile properties of modified bitumen by the force ductility method《沥青和沥青粘合剂 使用压力延展法测定改良沥青的拉伸性能》.pdf BS EN 13589-2008 Bitumen and bituminous binders - Determination of the tensile properties of modified bitumen by the force ductility method《沥青和沥青粘合剂 使用压力延展法测定改良沥青的拉伸性能》.pdf
  • BS EN 13590-2003 Packaging - Flexible carrier bags for the transport of various retail goods - General characteristics and test methods for the determination of volume and carrying.pdf BS EN 13590-2003 Packaging - Flexible carrier bags for the transport of various retail goods - General characteristics and test methods for the determination of volume and carrying.pdf
  • BS EN 13592-2017 Plastics sacks for household waste collection Types requirements and test methods《家庭废物收集用塑料袋 类型、要求和试验方法》.pdf BS EN 13592-2017 Plastics sacks for household waste collection Types requirements and test methods《家庭废物收集用塑料袋 类型、要求和试验方法》.pdf
  • 相关搜索

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

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