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

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

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

2、0)1.请编写函数 ReadDat(),从文件 IN.DAT中读取 1000个十进制整数到数组 xx中。请编写函数 Compute(),分别计算出 xx中奇数的个数 odd、偶数的个数 even、平均值 aver及方差 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; /*循环控制变量*/ for(i=0;i1000;i+) /*依次取每个数*/ if(xxi%2!=0) odd+; /*求出 xx中奇数的个数 odd*/ else even+; /*求出 xx中偶数的个数 even*/ aver+=xxi; /*求出 xx中元素的总和*/ aver/=MAX; /*求出

4、xx中元素的平均值*/ for(i=0;i1000;i+) totfc+=(xxi-aver)*(xxi-aver)/MAX; 考点 本题考查的知识点包括:C 语言中文件读函数,if 条件判断结构,对多个整数求平均值和方差的算法等。 解析 此题属于 4位数排序问题。分析题干要求,本题要求完成 ReadDat(void) 函数并实现 Compute()函数的功能,分析后可以归纳出 3个关键点:关键点 1如何实现从已打开的文件中依次读取数据到数组的操作;关键点 2如何分离并统计出奇数偶数的个数和所有数的和值,并计算平均值;关键点 3如何计算方差。 接着分析每一步的解决方法,对于关键点 1可以使用 C语言的库函数 fscanf();关键点 2通过包含 if判断语句和逻辑表达式可以实现;关键点 3根据题目中已给出的公式和之前保存的数据可以计算出偶数的方差。 文件操作函数 fscanf()和 feof()的用法;if 判断语句中逻辑表达式;对方差计算公式运用错误。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 3372-009-2008 Aerospace series - Connectors electrical circular medium and high contact density scoop-proof with bayonet coupling operating temperatures -65 C to 175 C or 20.pdf DIN EN 3372-009-2008 Aerospace series - Connectors electrical circular medium and high contact density scoop-proof with bayonet coupling operating temperatures -65 C to 175 C or 20.pdf
  • DIN EN 3372-011-2008 Aerospace series - Connectors electrical circular medium and high contact density scoop-proof with bayonet coupling operating temperatures -65 C to 175 C or 20.pdf DIN EN 3372-011-2008 Aerospace series - Connectors electrical circular medium and high contact density scoop-proof with bayonet coupling operating temperatures -65 C to 175 C or 20.pdf
  • DIN EN 3373-001-2008 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 001 Technical specification German and English version EN 3373-.pdf DIN EN 3373-001-2008 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 001 Technical specification German and English version EN 3373-.pdf
  • DIN EN 3373-002-2009 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 002 General and list of product standard German and English ver.pdf DIN EN 3373-002-2009 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 002 General and list of product standard German and English ver.pdf
  • DIN EN 3373-007-2012 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 007 Nickel plated aluminium terminal lugs for crimping on nicke.pdf DIN EN 3373-007-2012 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 007 Nickel plated aluminium terminal lugs for crimping on nicke.pdf
  • DIN EN 3373-008-2012 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 008 Copper lugs nickel plated ring shaped for copper conductors.pdf DIN EN 3373-008-2012 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 008 Copper lugs nickel plated ring shaped for copper conductors.pdf
  • DIN EN 3373-010-2009 de en 9700 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 010 Terminal lugs ring shaped tin plated for crimpin.pdf DIN EN 3373-010-2009 de en 9700 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 010 Terminal lugs ring shaped tin plated for crimpin.pdf
  • DIN EN 3373-011-2009 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 011 Terminal lugs ring shaped nickel plated for crimping on cop.pdf DIN EN 3373-011-2009 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 011 Terminal lugs ring shaped nickel plated for crimping on cop.pdf
  • DIN EN 3373-012-2007 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 012 In-line splices insulated and sealed for crimping on copper.pdf DIN EN 3373-012-2007 Aerospace series - Terminal lugs and in-line splices for crimping on electric conductors - Part 012 In-line splices insulated and sealed for crimping on copper.pdf
  • 相关搜索

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

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