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

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

1、国家三级(数据库技术)机试模拟试卷 119及答案与解析 一、程序设计题 1 函数 ReadDat()实现从文件 IN.dat中读取 1000个十进制整数到数组 xx中。编写函数 Compute(),其功能是:分别计算出 xx数组中奇数的个数 odd、奇数的平均值ave1、偶数的个数 even、偶数的平均值 ave2,以及所有奇数的方差 totfc的值。调用函数 WritcDat(),把结果输出到 OUT.dat文件中。计算方差的公式如下:式中, N为奇数的个数; xxi为奇数; ave1为奇数的平均值。 原始数据文件存放的格式 是:每行存放 10个数 (每个数均大于 0且小于等于 2000),

2、并用逗号隔开。 注意:部分源程序已经给出。请勿改动主函数 main()、读函数 ReadDat()和输出数据函数 WriteDat()的内容。 #include stdio.h #include stdlib.h #include string.h #define MAX 1000int xxMAX, odd = 0, even = 0;double ave1 = 0.0, ave2 = 0.0, totfc = 0.0;void WriteDat(void);int ReadDat(void) FILE *fp; int i, j; if (fp = fopen(“IN.dat“, “r“)

3、 = NULL) return 1; for (i=0;i 100; i+) for (j=0; j 10; j+) 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. dat 不能打开 ! 007n“); return; Compute ( ); printf ( “ODD=%dnEVEN=

4、dnAVE1=% fnAVE2=% f nTOTFC=% f n“, odd, even, ave1, ave2, totfc); WriteDat ();void WriteDat(void) FILE *fp; fp = fopen(“OUT.dat“, “w“); fprintf(fp, “%dn%dn%fn%fn%fn“, odd, even, ave1, ave2, totfc); fclose (fp); 国家三级(数据库技术)机试模拟试卷 119答案与解析 一、程序设计题 1 【正确答案】 void Compute (void) int i, yyMAX; for (i=0;

5、i 1000; i+) if (xxi %2) odd+; ave1 += xxi; yyodd-1 = xxi; else even+; ave2 += xxi; ave1 /= odd; ave2 /= even; for (i=0; i odd; i+) totfc += (yyi-ave1)* (yyi-ave1)/odd; 解题思路 对数组 xxi中的 1000个整数逐个进行扫描处理,如果 xxi对 2的余数为 1,则 xxi为奇数,变量 odd加 1,把 xxi的值加到变量 ave1中,同时把 xxi的值输给数组 yy:否则 xxi为偶数,变量 even加 1,把 xxi的值加到变量 ave2中。循环结束后,变量 ave1的值即为所有奇数的和,用 ave1的值除以奇数的个数odd,就得到所有奇数的平均值;变量 ave2的值即为所有偶数的和,用 ave2的值除以偶数的个数 even,就得到所有偶数的平均值。最后在 for循环语句中根据方差的公式求出所有奇数的方差。 【知识模块】 三级数据库技术机试模拟

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 3684-1996 Aerospace Series Test Methods Titanium Alloy Wrought Products Determination of Beta Ray Transus Temperature Metallographic Method Edition P 1《航空航天系列.钛合金锻件产品BET.pdf AECMA PREN 3684-1996 Aerospace Series Test Methods Titanium Alloy Wrought Products Determination of Beta Ray Transus Temperature Metallographic Method Edition P 1《航空航天系列.钛合金锻件产品BET.pdf
  • AECMA PREN 3685-1991 Aerospace Series Bolts in Heat Resisting Steel FE-PA92HT (A286) Classification 1100 MPa 650 Degrees C Technical Specification Issue P 1《航空航天系列.耐热钢 FE-PA92HT(A2.pdf AECMA PREN 3685-1991 Aerospace Series Bolts in Heat Resisting Steel FE-PA92HT (A286) Classification 1100 MPa 650 Degrees C Technical Specification Issue P 1《航空航天系列.耐热钢 FE-PA92HT(A2.pdf
  • AECMA PREN 3686-1991 Aerospace Series Bolts with Double Hexagon Head Relieved Shank Long Thread in Heat Resisting Steel FE-PA92HT (A286) Silver Plated Classification 1100 MPa 650 D.pdf AECMA PREN 3686-1991 Aerospace Series Bolts with Double Hexagon Head Relieved Shank Long Thread in Heat Resisting Steel FE-PA92HT (A286) Silver Plated Classification 1100 MPa 650 D.pdf
  • AECMA PREN 3687-1991 Aerospace Series Bolts Normal Hexagon Head Relieved Shank Long Thread in Heat Resisting Steel FE-PA92HT (A286) Silver Plated Classification 1100 MPa 650 Degree.pdf AECMA PREN 3687-1991 Aerospace Series Bolts Normal Hexagon Head Relieved Shank Long Thread in Heat Resisting Steel FE-PA92HT (A286) Silver Plated Classification 1100 MPa 650 Degree.pdf
  • AECMA PREN 3688-1994 Aerospace Series T-Ring Fillers in Titanium Alloy for Welding Pipes 14 000 kPa Nominal Pressure Edition P 1《航空航天系列.T环填充钛合金焊接管14 000千帕》.pdf AECMA PREN 3688-1994 Aerospace Series T-Ring Fillers in Titanium Alloy for Welding Pipes 14 000 kPa Nominal Pressure Edition P 1《航空航天系列.T环填充钛合金焊接管14 000千帕》.pdf
  • AECMA PREN 3689-1994 Aerospace Series T-Ring Fillers in Titanium Alloy for Welding Pipes 28 000 kPa Nominal Pressure Edition P 1《航空航天系列.T环填充钛合金焊接管28 000千帕》.pdf AECMA PREN 3689-1994 Aerospace Series T-Ring Fillers in Titanium Alloy for Welding Pipes 28 000 kPa Nominal Pressure Edition P 1《航空航天系列.T环填充钛合金焊接管28 000千帕》.pdf
  • AECMA PREN 3690-1994 Aerospace Series Pipe Coupling 8 Degree 30' in Titanium Alloy Unions Bulkhead Long Edition P 1《航空航天系列.钛合金管连接8°30′长防水壁》.pdf AECMA PREN 3690-1994 Aerospace Series Pipe Coupling 8 Degree 30' in Titanium Alloy Unions Bulkhead Long Edition P 1《航空航天系列.钛合金管连接8°30′长防水壁》.pdf
  • AECMA PREN 3691-1994 Aerospace Series Pipe Coupling 8 Degree 30' in Titanium Alloy Unions Bulkhead Long Welded Edition P 1《航空航天系列.钛合金管连接8°30′长防水壁》.pdf AECMA PREN 3691-1994 Aerospace Series Pipe Coupling 8 Degree 30' in Titanium Alloy Unions Bulkhead Long Welded Edition P 1《航空航天系列.钛合金管连接8°30′长防水壁》.pdf
  • AECMA PREN 3696-1994 Aerospace Series Washers in Heat Resisting Steel Edition P 1《航空航天系列.抗热垫圈钢.P1版》.pdf AECMA PREN 3696-1994 Aerospace Series Washers in Heat Resisting Steel Edition P 1《航空航天系列.抗热垫圈钢.P1版》.pdf
  • 相关搜索

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

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