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

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

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

2、件 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“, “r“)=NULL) return 1; for(i=0; i100; i+) /*依次读取

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

4、lse even+; /*计算出 xx 中偶数的个数 even*/ ave2+=xxi; /*求偶数的和*/ ave1/=odd; /*求奇数的平均值*/ ave2/=even; /*求偶数的平均值*/ for(i=0; iodd; i+) totfc+=(tti-ave1)*(tti-ave1)/odd; /*求所有奇数的方差*/ 考点 本题考查的知识点包括:C 语言中文件读函数,if 条件判断结构,对多个整数求平均值和方差的算法等。 此题属于数学类问题。分析题干要求,得出解本题主要需解决 3 个问题:问题 1 如何实现从已打开的文件中依次读取数据到数组的操作,问题 2 如何分离并统计出奇数和偶数的个数及和值,并计算平均值;问题3 如何计算奇数的方差。 本题的解题思路为:首先使用 C 语言的库函数 fscanf()将文件中的数依次读入数组 xx 中,然后通过循环判断得出需要的数据(奇数个数、偶数个数、奇数及偶数的和);最后根据题目中已给出的公式和之前保存的数据计算出奇数的方差。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 12932-2015 Chemicals used for treatment of water intended for human consumption - Chemicals for emergency use - Sodium dichloroisocyanurate dihydrate German version EN 12932.pdf DIN EN 12932-2015 Chemicals used for treatment of water intended for human consumption - Chemicals for emergency use - Sodium dichloroisocyanurate dihydrate German version EN 12932.pdf
  • DIN EN 12933-2015 Chemicals used for treatment of water intended for human consumption - Chemicals for emergency use - Trichloroisocyanuric acid German version EN 12933 2015《人类生活用水.pdf DIN EN 12933-2015 Chemicals used for treatment of water intended for human consumption - Chemicals for emergency use - Trichloroisocyanuric acid German version EN 12933 2015《人类生活用水.pdf
  • DIN EN 12934-1999 Feather and down - Composition labelling of precessed feathers and down for use as sole filling material German version EN 12934 1999《羽毛和羽绒 作为单一填充料的加工羽毛和绒毛的成分标签》.pdf DIN EN 12934-1999 Feather and down - Composition labelling of precessed feathers and down for use as sole filling material German version EN 12934 1999《羽毛和羽绒 作为单一填充料的加工羽毛和绒毛的成分标签》.pdf
  • DIN EN 12935-2001 Feather and down - Hygiene and cleanliness requirements German version EN 12935 2001《羽毛和羽绒 卫生和清洁要求》.pdf DIN EN 12935-2001 Feather and down - Hygiene and cleanliness requirements German version EN 12935 2001《羽毛和羽绒 卫生和清洁要求》.pdf
  • DIN EN 12938-2000 Methods for the analysis of pewter - Determination of alloying and impurity element contents by atomic spectrometry (includes AC 2000) German version EN 12938 199.pdf DIN EN 12938-2000 Methods for the analysis of pewter - Determination of alloying and impurity element contents by atomic spectrometry (includes AC 2000) German version EN 12938 199.pdf
  • DIN EN 12939-2001 en 9818 Thermal performance of building materials and products - Determination of thermal resistance by means of guarded hot plate and heat flow meter methods - T.pdf DIN EN 12939-2001 en 9818 Thermal performance of building materials and products - Determination of thermal resistance by means of guarded hot plate and heat flow meter methods - T.pdf
  • DIN EN 1294-2000 Door leaves - Determination of the behaviour under humidity variations in successive uniform climates German version EN 1294 2000《门扉 连续标准气候下湿度变化时的状态测定》.pdf DIN EN 1294-2000 Door leaves - Determination of the behaviour under humidity variations in successive uniform climates German version EN 1294 2000《门扉 连续标准气候下湿度变化时的状态测定》.pdf
  • DIN EN 12940-2004 Footwear manufacturing wastes - Waste classification and management German version EN 12940 2004《鞋靴生产废弃物 废弃物分类和管理》.pdf DIN EN 12940-2004 Footwear manufacturing wastes - Waste classification and management German version EN 12940 2004《鞋靴生产废弃物 废弃物分类和管理》.pdf
  • DIN EN 12941-2009 Respiratory protective devices - Powered filtering devices incorporating a helmet or a hood - Requirements testing marking (includes A1 2003 and Amendment A2 2008.pdf DIN EN 12941-2009 Respiratory protective devices - Powered filtering devices incorporating a helmet or a hood - Requirements testing marking (includes A1 2003 and Amendment A2 2008.pdf
  • 相关搜索

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

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