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

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

1、国家三级(数据库技术)机试模拟试卷 120及答案与解析 一、程序设计题 1 请补充完整程序,使得程序能实现以下功能: 从文件 IN.dat中读取 200个整数至数组 number中,求出最大数 max及最大数的个数 cnt和数组 number中能被 3整除或能被 7整除的算术平均值 ave(保留 2位小数 )。把结果 max、 cnt、 ave输出到 OUT. dat文件中。 注意:部分程序、读数据函数 read_ dat (int number200)及输出格式已给出。 #include conio. h #include stdio. h #define N 200 void read_

2、dat(int numberN) int i, j; FILE *fp; fp = fopen(“IN. dat“, “r“); for (i=0; i 20; i+) for (j=0; j 10; j+) fscanf(fp, “%d,“, printf(“%d “, numberi*10+j); printf (“n“); fclose (fp); void main () int cnt, numberN, max; float ave; FILE *fw; int i, k; long j = 0; fw = fopen(“OUT.dat“, “w“); read_ dat (num

3、ber); / * / / * / printf(“nnmax=%d, cnt=%d, ave=%6.2fn“, max, cnt, ave); fprintf(fw, “%dn%dn%6.2fn“, max, cnt, ave); fclose (fw); 国家三级(数据库技术)机试模拟试卷 120答案与解析 一、程序设计题 1 【正确答案】 max = number0; for (i=1, k=0; i N; i+) if (numberi max) max = numberi; if (numberi%3=0 numberi%7=0) j += numberi; k+; for (i=0

4、 cnt=0; i N; i+) if (numberi = max) cnt+; ave = (float) (j*100/k)/100; 解题思路 用整型变量 max保存数组 number中元素的最大值,首先把数组 number的第一个元素 number0存入 max中;然后在 for循环语句中当循环变量 i从 1递增到 N-1时, 对数组 number中的每一个元素 numberi与 max进行比较,如果表达式 numberi max成立,则把数组元素 numberi的值存入变量 max中;再用表达式numberi%3=0 numberi%7=0判断 numberi能否被 3或 7整除,如果表达式结果值为真,则把数组元素 numberi的值与变量 j的值相加,同时计数变量 k加1。退出循环后,变量 max中的值就是数组 number中元素的最大值,再用 for循环语句对数组 number中的每一个元素与 max的值进行相等的判断,如果 numberi的值等于 max,则计数变量 cnt加 1。最后用表达式 (float)(j*100/k)/100求得数组number中能被 3整除或能被 7整除的算术平均值。 【知识模块】 三级数据库技术机试模拟

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 2591-C11-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C11 - Low Air Pressure Issue P 1《航空航天系列.光电连接元件 试验方法 C11部分 低压空气试验》.pdf AECMA PREN 2591-C11-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C11 - Low Air Pressure Issue P 1《航空航天系列.光电连接元件 试验方法 C11部分 低压空气试验》.pdf
  • AECMA PREN 2591-C12-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C12 - Air Leakage Issue P 1《航空航天系列.光电连接元件 试验方法 C12部分 泄气试验》.pdf AECMA PREN 2591-C12-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C12 - Air Leakage Issue P 1《航空航天系列.光电连接元件 试验方法 C12部分 泄气试验》.pdf
  • AECMA PREN 2591-C13-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C13 - Driving Rain (Artificial) Issue P 1《航空航天系列.光电连接元件 试验方法 C13部分 人工降雨》.pdf AECMA PREN 2591-C13-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C13 - Driving Rain (Artificial) Issue P 1《航空航天系列.光电连接元件 试验方法 C13部分 人工降雨》.pdf
  • AECMA PREN 2591-C14-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C14 - Immersion at Low Air Pressure Issue P 1《航空航天系列.光电连接元件 试验方法 C14部分 低气压.pdf AECMA PREN 2591-C14-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C14 - Immersion at Low Air Pressure Issue P 1《航空航天系列.光电连接元件 试验方法 C14部分 低气压.pdf
  • AECMA PREN 2591-C15-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C15 - Fluid Resistance Issue P 1《航空航天系列.光电连接元件 试验方法 C15部分 抗流体性》.pdf AECMA PREN 2591-C15-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C15 - Fluid Resistance Issue P 1《航空航天系列.光电连接元件 试验方法 C15部分 抗流体性》.pdf
  • AECMA PREN 2591-C16-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C16 - Ozone Resistance Issue P 1《航空航天系列.光电连接元件 试验方法 C16部分 抗臭氧性》.pdf AECMA PREN 2591-C16-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C16 - Ozone Resistance Issue P 1《航空航天系列.光电连接元件 试验方法 C16部分 抗臭氧性》.pdf
  • AECMA PREN 2591-C17-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C17 - Flammability Issue P 1《航空航天系列.光电连接元件 试验方法 C17部分 可燃性》.pdf AECMA PREN 2591-C17-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C17 - Flammability Issue P 1《航空航天系列.光电连接元件 试验方法 C17部分 可燃性》.pdf
  • AECMA PREN 2591-C18-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C18 - Fire-Resistance Issue P 1《航空航天系列.光电连接元件 试验方法 C18部分 防火》.pdf AECMA PREN 2591-C18-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C18 - Fire-Resistance Issue P 1《航空航天系列.光电连接元件 试验方法 C18部分 防火》.pdf
  • AECMA PREN 2591-C19-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C19 - Gas-Tightness of Solderless Wrapped Connections Issue P 1《航空航天系列.光电连.pdf AECMA PREN 2591-C19-1992 Aerospace Series Elements of Electrical and Optical Connection Test Methods Part C19 - Gas-Tightness of Solderless Wrapped Connections Issue P 1《航空航天系列.光电连.pdf
  • 相关搜索

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

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