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

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

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

2、100.00)1.请编制函数 ReadDat()实现从文件 IN93.DAT 中读取 1000 个十进制整数到数组 xx 中。请编制函数 Compute()分别计算出 xx 中奇数的个数 odd、偶数的个数 even、平均值 aver 及方差 totfc 的值,最后调用函数 WriteDat()把结果输出到 OUT93.DAT 文件中。计算方差的公式如下:(分数:100.00)_正确答案:(int ReadDat(void)FILE *fp;int i,j;if(fP=fopen(“IN93.DAT“,“r“)=NULL)return 1;for(i=0;i100;i+)for(j=0;j10

3、j+)fscanf(fp,“%d,“,fscanf(fp,“/n“);if(feof(fp) break;fclose(fp);return 0;void Compute(void)int i,yyMAX;for (i=0;i1000;i+)if (xxi%2 !=0)odd+ +; /*求出 xx 中奇数的个数 odd*/elseeven+; /*求出 xx 中偶数的个数 even*/aver+=xx i; /*求出 xx 中元素的总和*/aver/=MAX; /*求出 xx 中元素的平均值*/for (i=0; i1000; i+)totfc+=(xxi-aver)*(xxi-aver)

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

展开阅读全文
相关资源
猜你喜欢
  • BS EN 2436-004-2006 Aerospace series - Paints and varnishes - Corrosion resistant chromate-free two component cold curing primer - High corrosion and fluid resistance with surface .pdf BS EN 2436-004-2006 Aerospace series - Paints and varnishes - Corrosion resistant chromate-free two component cold curing primer - High corrosion and fluid resistance with surface .pdf
  • BS EN 2436-005-2006 Aerospace series - Paints and varnishes - Corrosion resistant chromate-free two component cold curing primer - For exterior use with surface preparation toleran.pdf BS EN 2436-005-2006 Aerospace series - Paints and varnishes - Corrosion resistant chromate-free two component cold curing primer - For exterior use with surface preparation toleran.pdf
  • BS EN 2436-006-2006 Aerospace series - Paints and varnishes - Corrosion resistant chromate-free two component cold curing epoxy primer - High corrosion resistance for military appl.pdf BS EN 2436-006-2006 Aerospace series - Paints and varnishes - Corrosion resistant chromate-free two component cold curing epoxy primer - High corrosion resistance for military appl.pdf
  • BS EN 2437-2002 Aerospace series - Chromate conversion coatings (yellow) for aluminium and aluminium alloys《航空航天系列 铝及铝合金的铬酸盐转化涂层(黄色)》.pdf BS EN 2437-2002 Aerospace series - Chromate conversion coatings (yellow) for aluminium and aluminium alloys《航空航天系列 铝及铝合金的铬酸盐转化涂层(黄色)》.pdf
  • BS EN 2438-2008 Aerospace series - Steel FE-PL2102 (35NiCr6) - 900 MPa Rm 1100 MPa - Bars - De 40 mm《航空航天系列 钢FE-PL2102(35NiCr6) 900 MPa≤Rm≤1100 MPa 棒材 De≤40 mm》.pdf BS EN 2438-2008 Aerospace series - Steel FE-PL2102 (35NiCr6) - 900 MPa Rm 1100 MPa - Bars - De 40 mm《航空航天系列 钢FE-PL2102(35NiCr6) 900 MPa≤Rm≤1100 MPa 棒材 De≤40 mm》.pdf
  • BS EN 2439-2009 Aerospace series - Steel FE-PL2102 (34NiCr6) - 900 MPa Rm 1100 MPa - Forgings - De 40 mm《航空航天系列 钢FE-PL2102(34NiCr6) 900 MPa≤Rm≤1100 Mpa 铸件 De≤40 mm》.pdf BS EN 2439-2009 Aerospace series - Steel FE-PL2102 (34NiCr6) - 900 MPa Rm 1100 MPa - Forgings - De 40 mm《航空航天系列 钢FE-PL2102(34NiCr6) 900 MPa≤Rm≤1100 Mpa 铸件 De≤40 mm》.pdf
  • BS EN 2446-2008 Aerospace series - Steel FE-PL1503 (35CrMo4) - 1100 MPa Rm 1300 MPa - Bars - De 25 mm《航空航天系列 钢FE-PL1503(35CrMo4) 1100 MPa≤Rm≤1300 MPa 棒材 De≤25 mm》.pdf BS EN 2446-2008 Aerospace series - Steel FE-PL1503 (35CrMo4) - 1100 MPa Rm 1300 MPa - Bars - De 25 mm《航空航天系列 钢FE-PL1503(35CrMo4) 1100 MPa≤Rm≤1300 MPa 棒材 De≤25 mm》.pdf
  • BS EN 2448-2008 Aerospace series - Steel FE-PL1503 (35CrMo4) - 900 MPa Rm 1100 MPa - Bars - De 40 mm《航空航天系列 钢FE-PL1503(35CrMo4) 900 MPa≤Rm≤1100 MPa 棒材 De≤40 mm》.pdf BS EN 2448-2008 Aerospace series - Steel FE-PL1503 (35CrMo4) - 900 MPa Rm 1100 MPa - Bars - De 40 mm《航空航天系列 钢FE-PL1503(35CrMo4) 900 MPa≤Rm≤1100 MPa 棒材 De≤40 mm》.pdf
  • BS EN 246-2003 Sanitary tapware - General specifications for flow rate regulators《卫生设备用水龙头 流速调节器通用规范》.pdf BS EN 246-2003 Sanitary tapware - General specifications for flow rate regulators《卫生设备用水龙头 流速调节器通用规范》.pdf
  • 相关搜索

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

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