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

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

1、计算机三级数据库技术-93 及答案解析(总分:100.00,做题时间:90 分钟)1.请编写程序,要求:将文件 IN.DAT 中的 200 个整数读入数组 xx 中,求出数组 xx 中的最大数 max 及最大数的个数 cnt 和数组 xx 中能被 3 或 7 整除的数的算术平均值 pj(保留两位小数),并将结果max,cnt,pj 输出到 OUT.DAT 中。 勿改动主函数 main()、读函数 read_dat()的内容。读函数 read_dat(int xx200)及输出格式已给出。 试题程序 #includestdlib.h #includestdio.h #define N 200 v

2、oid read dat(int xxN) int i, j; FILE*fp; fp=fopen“IN.DAT“, “r“); for(i=0; i20; i+) for(j=0; j10; j+) fscanf(fp, “%d,“, printf(“%d“, xxi*10+j); printf(“n“); fclose(fp); void main() int i, k, cnt, xxN, max; float pj; FILE*fw; long j=0; system(“CLS“); fw=fopen(“OUT.DAT“, “w“); read_dat(xx); printf(“nnm

3、ax=%d, cnt=%d, pj=%6.2fn“, max, cnt, pj); fprintf(fw, “%dn%dn%6.2fn“, max, cnt, pj); fclose(fw); (分数:100.00)_计算机三级数据库技术-93 答案解析(总分:100.00,做题时间:90 分钟)1.请编写程序,要求:将文件 IN.DAT 中的 200 个整数读入数组 xx 中,求出数组 xx 中的最大数 max 及最大数的个数 cnt 和数组 xx 中能被 3 或 7 整除的数的算术平均值 pj(保留两位小数),并将结果max,cnt,pj 输出到 OUT.DAT 中。 勿改动主函数 mai

4、n()、读函数 read_dat()的内容。读函数 read_dat(int xx200)及输出格式已给出。 试题程序 #includestdlib.h #includestdio.h #define N 200 void read dat(int xxN) int i, j; FILE*fp; fp=fopen“IN.DAT“, “r“); for(i=0; i20; i+) for(j=0; j10; j+) fscanf(fp, “%d,“, printf(“%d“, xxi*10+j); printf(“n“); fclose(fp); void main() int i, k, cn

5、t, xxN, max; float pj; FILE*fw; long j=0; system(“CLS“); fw=fopen(“OUT.DAT“, “w“); read_dat(xx); printf(“nnmax=%d, cnt=%d, pj=%6.2fn“, max, cnt, pj); fprintf(fw, “%dn%dn%6.2fn“, max, cnt, pj); fclose(fw); (分数:100.00)_正确答案:()解析:void main() int i, k, cnt, xxN, max; float pj; FILE*fw; long j=0; system(

6、CLS“); fw=fopen(“out.dat“, “w“); read_dat(xx); max=xx0; for(i=1, k=0; iN; i+) if(xximax) max=xxi; /*求出数组 xx 中最大数 max*/ if(xxi%3=0 |xxi%7=0) j+=xxi; /*求出数组 xx 中值能被 3 整除或能被 7 整除的数的总和*/ k+; for(i=0, cnt=0; iN; i+) if(xxi=max) cnt+; /*求出数组 xx 中最大数 max 的个数*/ pj=(float)(j*100/k)/100; /*求出数组 xx 中值能被 3 整除或

7、能被 7 整除的数的平均值*/ printf(“nnmax=%d, cnt=%d, pj=%6.2fn“, max, cnt, pj); fprintf(fw, “%dn%dn%6.2fn“, max, cnt, pj); fclose(fw); 考点 本题考查对多个整数的筛选、统计以及计算平均值,考查的知识点只要包括:多位整数的数位分解算法,逻辑表达式,计算平均值的算法。 首先通读题目,得知此题属于 4 位数的筛选题型;其次分析题干要求,本题要求补充 main 中空白部分,进一步分析,可以归纳出 3 个关键点:关键点 1 如何找出数组中最大数的值并统计其个数;关键点 2 如何通过条件“可以被 7 或 3 整除”在数组中筛选出满足条件的数;关键点 3 如何计算平均值。接着分析每一步的解决方法,对于关键点 1 通过循环使用起泡法找出其中最大的数,同时统计其个数;关键点 2 通过if 判断结构和逻辑表达式可以实现;关键点 3 通过之前找到满足条件的数的和及其个数计算出平均值。

展开阅读全文
相关资源
猜你喜欢
  • ISO IWA 12-2013 Guidelines on the application of ISO 9001 2008 in policing organizations (First Edition)《警务组织ISO 9001-2008应用指南 (第一版)》.pdf ISO IWA 12-2013 Guidelines on the application of ISO 9001 2008 in policing organizations (First Edition)《警务组织ISO 9001-2008应用指南 (第一版)》.pdf
  • ISO IWA 13-2014 Multiple resource evaluation guideline (First Edition)《多种资源评估指南 (第一版)》.pdf ISO IWA 13-2014 Multiple resource evaluation guideline (First Edition)《多种资源评估指南 (第一版)》.pdf
  • ISO IWA 14-1-2013 Vehicle security barriers - Part 1 Performance requirement vehicle impact test method and performance rating (First Edition Corrected Version .pdf ISO IWA 14-1-2013 Vehicle security barriers - Part 1 Performance requirement vehicle impact test method and performance rating (First Edition Corrected Version .pdf
  • ISO IWA 14-2-2013 Vehicle security barriers - Part 2 Application (First Edition Corrected Version 01 15 2014)《车辆安全屏障 第2部分 应用 (第一版 修正版本01 15 2014)》.pdf ISO IWA 14-2-2013 Vehicle security barriers - Part 2 Application (First Edition Corrected Version 01 15 2014)《车辆安全屏障 第2部分 应用 (第一版 修正版本01 15 2014)》.pdf
  • ISO IWA 15-2015 Specification and method for the determination of performance of automated liquid handling systems (First Edition)《测定自动化液体处理系统性能的规范和方法 (第一版)》.pdf ISO IWA 15-2015 Specification and method for the determination of performance of automated liquid handling systems (First Edition)《测定自动化液体处理系统性能的规范和方法 (第一版)》.pdf
  • ISO IWA 16-2015 International harmonized method(s) for a coherent quantification of CO2e emissions of freight transport (First Edition)《货物运输二氧化碳当量排放一致量化的国际统一方法 .pdf ISO IWA 16-2015 International harmonized method(s) for a coherent quantification of CO2e emissions of freight transport (First Edition)《货物运输二氧化碳当量排放一致量化的国际统一方法 .pdf
  • ISO IWA 17-2014 Information and operations security and integrity requirements for lottery and gaming organizations (First Edition)《彩票及博彩组织的信息和操作安全性及完整性要求 (第一版).pdf ISO IWA 17-2014 Information and operations security and integrity requirements for lottery and gaming organizations (First Edition)《彩票及博彩组织的信息和操作安全性及完整性要求 (第一版).pdf
  • ISO IWA 6-2008 Guidelines for the management of drinking water utilities under crisis conditions《恶化环境下饮用水设施的管理指南》.pdf ISO IWA 6-2008 Guidelines for the management of drinking water utilities under crisis conditions《恶化环境下饮用水设施的管理指南》.pdf
  • ISO IWA 8-2009 Tableware giftware jewellery luminariesGlass clarityClassification and test method《餐具、礼品、珠宝、灯具 玻璃透明度 分类和试验方法》.pdf ISO IWA 8-2009 Tableware giftware jewellery luminariesGlass clarityClassification and test method《餐具、礼品、珠宝、灯具 玻璃透明度 分类和试验方法》.pdf
  • 相关搜索

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

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