[计算机类试卷]国家三级(数据库技术)机试模拟试卷122及答案与解析.doc

上传人:jobexamine331 文档编号:495266 上传时间:2018-11-28 格式:DOC 页数:2 大小:30KB
下载 相关 举报
[计算机类试卷]国家三级(数据库技术)机试模拟试卷122及答案与解析.doc_第1页
第1页 / 共2页
[计算机类试卷]国家三级(数据库技术)机试模拟试卷122及答案与解析.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家三级(数据库技术)机试模拟试卷 122及答案与解析 一、程序设计题 1 函数 ReadDat()实现从文件 IN.dat中读取 1000个十进制整数到数组 xx中;请编写函数 Compute()分别计算出数组 xx中奇数的个数 odd、偶数的个数 even,以及所有数的平均值 aver和方差 totfc的值。最后调用函数 WriteDat(),把结果输出到OUT. dat文件中。 计算方差的公式如下: 原始数据文件存放的格式是:每行存放 10个数 (每个数均大于 0且小于等于 2000),并用逗号隔开。 注意:部分源程序已经给出 。请勿改动主函数 main()、读函数 ReadDat()和

2、输出数据函数 WriteDat()的内容。 #include stdio. h #include stdlib. h#include string. h #define MAX 1000int xxMAX, odd = 0, even = 0;double aver = 0.0, totfc = 0.0;void WriteDat(void);int ReadDat(void) FILE *fp; int i, j; if (fp = fopen(“IN. dat“, “r“) = NULL) return 1; for (i=0; i 100; i+) for (j=0; j 10; j+)

3、 fscanf(fp, “%d,“, fscanf(fp, “n“); if (feof(fp) break; fclose(fp); return 0;void Compute(void)void main () int i; for (i=0; i MAX; i+) xxi = 0; if (ReadDat() printf (“ 数据文件 IN. dar 不能打开 ! 007n“); return; Compute ( ); printf(“odd=%dneven=%dnaver=%fntotfc=%fn“, odd, even, aver, totfc); WriteDat ();vo

4、id WriteDat(void) FILE *fp; fp = fopen(“OUT.dat“, “w“); fprintf(fp, “%dn%dn%fn%fn“, odd, even, aver, totfc); fclose (fp); 国家三级(数据库技术)机试模拟试卷 122答案与解析 一、程序设计题 1 【正确答案】 void Compute (void) int i; for (i=0; i 1000; i+) if (xx i %2) odd+; else even+; aver = aver+ xxi; aver /= MAX; for (i=0; i 1000; i+) totfc += (xxi-aver)*(xxi-aver)/MAX; 解题思路 对数组 xxi中的 1000个整数逐个进行扫描处理,如果 xxi对 2的余数为 1,则 xxi为奇数,变量 odd加 1;否则 xxi为偶数,变量 even加 1。把 xxi的值与变量 aver相加存入变量 aver中。退出循环时,变量 aver的值除以 MAX就得到平均值。最后在 for循环语句中根据方差的公式求出所有数的方差。 【知识模块】 三级数据库技术机试模拟

展开阅读全文
相关资源
猜你喜欢
  • ASTM B746 B746M-2002(2012) Standard Specification for Corrugated Aluminum Alloy Structural Plate for Field-Bolted Pipe Pipe-Arches and Arches《现场螺栓安装管、管拱和拱桥用瓦楞铝合金结构标准规格》.pdf ASTM B746 B746M-2002(2012) Standard Specification for Corrugated Aluminum Alloy Structural Plate for Field-Bolted Pipe Pipe-Arches and Arches《现场螺栓安装管、管拱和拱桥用瓦楞铝合金结构标准规格》.pdf
  • ASTM B746 B746M-2016 Standard Specification for Corrugated Aluminum Alloy Structural Plate for Field-Bolted Pipe Pipe-Arches and Arches《现场栓接管 管拱和拱用波纹铝合金结构板的标准规格》.pdf ASTM B746 B746M-2016 Standard Specification for Corrugated Aluminum Alloy Structural Plate for Field-Bolted Pipe Pipe-Arches and Arches《现场栓接管 管拱和拱用波纹铝合金结构板的标准规格》.pdf
  • ASTM B747-2007 Standard Specification for Copper-Zirconium Alloy Sheet and Strip《铜锆合金钢板材和带材用标准规范》.pdf ASTM B747-2007 Standard Specification for Copper-Zirconium Alloy Sheet and Strip《铜锆合金钢板材和带材用标准规范》.pdf
  • ASTM B747-2011 Standard Specification for Copper-Zirconium Alloy Sheet and Strip《铜锆合金薄板和条板的标准规格》.pdf ASTM B747-2011 Standard Specification for Copper-Zirconium Alloy Sheet and Strip《铜锆合金薄板和条板的标准规格》.pdf
  • ASTM B747-2015 Standard Specification for Copper-Zirconium Alloy Sheet and Strip 《铜锆合金板材和带材的标准规格》.pdf ASTM B747-2015 Standard Specification for Copper-Zirconium Alloy Sheet and Strip 《铜锆合金板材和带材的标准规格》.pdf
  • ASTM B748-1990(2006) Standard Test Method for Measurement of Thickness of Metallic Coatings by Measurement of Cross Section with a Scanning Electron Microscope《用扫描电子显微镜测量横截面测定金属涂层厚.pdf ASTM B748-1990(2006) Standard Test Method for Measurement of Thickness of Metallic Coatings by Measurement of Cross Section with a Scanning Electron Microscope《用扫描电子显微镜测量横截面测定金属涂层厚.pdf
  • ASTM B748-1990(2010) Standard Test Method for Measurement of Thickness of Metallic Coatings by Measurement of Cross Section with a Scanning Electron Microscope《扫描电子显微镜测量横截面测定金属涂层厚度.pdf ASTM B748-1990(2010) Standard Test Method for Measurement of Thickness of Metallic Coatings by Measurement of Cross Section with a Scanning Electron Microscope《扫描电子显微镜测量横截面测定金属涂层厚度.pdf
  • ASTM B748-1990(2016) Standard Test Method for Measurement of Thickness of Metallic Coatings by Measurement of Cross Section with a Scanning Electron Microscope《通过用扫描电子显微镜测量横截面来测量金属.pdf ASTM B748-1990(2016) Standard Test Method for Measurement of Thickness of Metallic Coatings by Measurement of Cross Section with a Scanning Electron Microscope《通过用扫描电子显微镜测量横截面来测量金属.pdf
  • ASTM B749-2003 Standard Specification for Lead and Lead Alloy Strip Sheet and Plate Products《铅和铅合金带材、薄板和板材产品标准规范》.pdf ASTM B749-2003 Standard Specification for Lead and Lead Alloy Strip Sheet and Plate Products《铅和铅合金带材、薄板和板材产品标准规范》.pdf
  • 相关搜索

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

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