[计算机类试卷]原国家四级机试模拟试卷2及答案与解析.doc

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

1、原国家四级机试模拟试卷 2及答案与解析 一、程序设计题 1 已知数据文件 in. dat中存有 10组每组 20个四位数的数据,每个数据间用空格分隔,调用读函数 ReadDat()把这 10组数据存人数组 aa中 (其中, aa定义为 int aa1020)。请编制一函数 jsVal(),其功能是;首先去掉每组中首尾位置的两个数,接着计算其余 18个数的算术平均值,并将计算结果依次存人数组 bb中 (其中,数组 bb定义为 float bb10),然后把数组 bb中的值按从大到小的顺序进行排序,排序后结果仍存人数组 bb中,最后调用写函数 WriteDat()把结果 bb输出到文件 out.

2、dat中。 注意:部分源程序已给出。 程序中已定义全局变量: aa1020、 bb10。 请勿改动数据文件 in. dat中的任何数据、主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。 .试题程序 # include stdio. h int aa1020 float bb10 void jsVal() void ReadDat() int i, j FILE * fP; fp = fopen(“in.darn“,“r“) for(i=0; i 10;i+) for(j=0; j 20; j+) fscanf(fP,“%d“, aaij) fclose(p

3、) void main() int i ReadDat(); / * 读数据 * / jsVal(); / * 按要求计算 * / for(i=0; i 10; i+) /* 从屏幕输出结果 * / printf(“%6.2lfn“, bbi); WriteDat() FILE * fp; int i; fp = fopen(“out, dat“, “w“) for(i=0; i 10; i+) fprintf(fp,“%6.21fn, bbi) fclose(fp); 原国家四级机试模拟试卷 2答案与解析 一、程序设计题 1 【正确答案】 void jsVal() int i,j,k,t,y; float sum=0; for(i=0; i 10; i+) for(y=0; y 20; y+) sum=sum+aaiy bbi=(sum-aai0-aai19)/18; sum=0; for(k=0; k 10; k+) for(i=0; i 10-k; i+) if(bbi bbi+1) t=bbi; bbi=bbi+1; bbi+1=t;

展开阅读全文
相关资源
猜你喜欢
  • ASD-STAN PREN 4644-201-2014 Aerospace series Connector electrical and optical rectangular modular rectangular inserts operating temperature 175 (or 125 continuous Part 201 Locking .pdf ASD-STAN PREN 4644-201-2014 Aerospace series Connector electrical and optical rectangular modular rectangular inserts operating temperature 175 (or 125 continuous Part 201 Locking .pdf
  • ASD-STAN PREN 4645-001-2008 Aerospace series Connectors optical circular single and multipin coupled by threaded ring self-locking 1 25 mm diameter ferrule with removable alignment.pdf ASD-STAN PREN 4645-001-2008 Aerospace series Connectors optical circular single and multipin coupled by threaded ring self-locking 1 25 mm diameter ferrule with removable alignment.pdf
  • ASD-STAN PREN 4645-002-2008 Aerospace series Connectors optical circular single and multipin coupled by threaded ring self-locking 1 25 mm diameter ferrule with removable alignment.pdf ASD-STAN PREN 4645-002-2008 Aerospace series Connectors optical circular single and multipin coupled by threaded ring self-locking 1 25 mm diameter ferrule with removable alignment.pdf
  • ASD-STAN PREN 4645-003-2008 Aerospace series Connectors optical circular single and multipin coupled by threaded ring self-locking 1 25 mm diameter ferrule with removable alignment.pdf ASD-STAN PREN 4645-003-2008 Aerospace series Connectors optical circular single and multipin coupled by threaded ring self-locking 1 25 mm diameter ferrule with removable alignment.pdf
  • ASD-STAN PREN 4645-004-2008 Aerospace series Connectors optical circular single and multipin coupled by threaded ring self-locking 1 25 mm diameter ferrule with removable alignment.pdf ASD-STAN PREN 4645-004-2008 Aerospace series Connectors optical circular single and multipin coupled by threaded ring self-locking 1 25 mm diameter ferrule with removable alignment.pdf
  • ASD-STAN PREN 4645-005-2008 Aerospace series Connectors optical circular single and multipin coupled by threaded ring self-locking 1 25 mm diameter ferrule with removable alignment.pdf ASD-STAN PREN 4645-005-2008 Aerospace series Connectors optical circular single and multipin coupled by threaded ring self-locking 1 25 mm diameter ferrule with removable alignment.pdf
  • ASD-STAN PREN 4649-2008 Aerospace series Handheld fire extinguishers with synthesis gases for aircraft use Technical specification and qualification conditions (Edition P 1)《航空航天系列.pdf ASD-STAN PREN 4649-2008 Aerospace series Handheld fire extinguishers with synthesis gases for aircraft use Technical specification and qualification conditions (Edition P 1)《航空航天系列.pdf
  • ASD-STAN PREN 4650-2008 Aerospace series Wire and cable marking process UV Laser (Edition P 1)《航空航天系列 电线和电缆标识工序 紫外激光器 第P1版》.pdf ASD-STAN PREN 4650-2008 Aerospace series Wire and cable marking process UV Laser (Edition P 1)《航空航天系列 电线和电缆标识工序 紫外激光器 第P1版》.pdf
  • ASD-STAN PREN 4651-2011 Aerospace series Copper-clad aluminium alloy conductors for electrical cables Product standard (Edition P 2).pdf ASD-STAN PREN 4651-2011 Aerospace series Copper-clad aluminium alloy conductors for electrical cables Product standard (Edition P 2).pdf
  • 相关搜索

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

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