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

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

1、三级数据库技术-501 及答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.已知在 in.dat 中存有若干个(个数200)四位数字的正整数,函数 ReadDat()读取这若干个正整数并存入数组 xx 中。请编制函数 CalValue(),其功能要求:1求出该文件中共有多少个正整数 totNum;2求这些正整数右移 1 位二进制位后,产生的新数是奇数的数的个数 totCnt,以及满足此条件的这些正整数(右移前的值)的算术平均值 totPjz。最后 main()函数调用函数 WriteDat()把所求的结果输出到文件out.dat 中。 请

2、勿改动数据文件 in.dat 中的任何数据,主函数 main()、读函数 ReadDat()和输出函数 WriteDat()的内容。 #include stdio.h #define MAXNUM 200 int xxMAXNUM; int totNum=0; /文件 in.dat 中共有多少个正整数 int totCnt=0; /符合条件的正整数的个数 double totPjz=0.0; /平均值 int ReadDat(void); void WriteDat(void); void CalValue(void) void main() int i; for(i=0; iMAXNUM;

3、i+) xxi=0; if(ReadDat() printf(“数据文件 in.dat 不能打开!007n“); return; CalValue(); printf(“文件 in.dat 中共有正整数=%d 个n“, totNum); printf(“符合条件的正整数的个数=%d 个n“, totCnt); printf(“平均值=%.2lfn“, totPjz); WriteDat(); /*读取这若干个正整数并存入数组 xx 中*/ int ReadDat(void) FILE *fp; int i=0; if(fp=fopen(“in.dat“, “r“)=NULL) return 1

4、; while(!feof(fp) fscanf(fp, “%d, “, fclose(fp); return 0; /*把计算结果存入文件 out.dat 中*/ void WriteDat(void) FILE *fp; fp=fopen(“out.dat“, “w“); fprintf(fp, “%dn%dn%.2lfn“, totNum, totCnt, totPjz); fclose(fp); (分数:100.00)_三级数据库技术-501 答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.已知在 in.dat 中存有若干个(个

5、数200)四位数字的正整数,函数 ReadDat()读取这若干个正整数并存入数组 xx 中。请编制函数 CalValue(),其功能要求:1求出该文件中共有多少个正整数 totNum;2求这些正整数右移 1 位二进制位后,产生的新数是奇数的数的个数 totCnt,以及满足此条件的这些正整数(右移前的值)的算术平均值 totPjz。最后 main()函数调用函数 WriteDat()把所求的结果输出到文件out.dat 中。 请勿改动数据文件 in.dat 中的任何数据,主函数 main()、读函数 ReadDat()和输出函数 WriteDat()的内容。 #include stdio.h #

6、define MAXNUM 200 int xxMAXNUM; int totNum=0; /文件 in.dat 中共有多少个正整数 int totCnt=0; /符合条件的正整数的个数 double totPjz=0.0; /平均值 int ReadDat(void); void WriteDat(void); void CalValue(void) void main() int i; for(i=0; iMAXNUM; i+) xxi=0; if(ReadDat() printf(“数据文件 in.dat 不能打开!007n“); return; CalValue(); printf(“

7、文件 in.dat 中共有正整数=%d 个n“, totNum); printf(“符合条件的正整数的个数=%d 个n“, totCnt); printf(“平均值=%.2lfn“, totPjz); WriteDat(); /*读取这若干个正整数并存入数组 xx 中*/ int ReadDat(void) FILE *fp; int i=0; if(fp=fopen(“in.dat“, “r“)=NULL) return 1; while(!feof(fp) fscanf(fp, “%d, “, fclose(fp); return 0; /*把计算结果存入文件 out.dat 中*/ vo

8、id WriteDat(void) FILE *fp; fp=fopen(“out.dat“, “w“); fprintf(fp, “%dn%dn%.2lfn“, totNum, totCnt, totPjz); fclose(fp); (分数:100.00)_正确答案:()解析:int i, j; long he=0; for(i=0; iMAXNUM; i+) if(xxi) totNum+; for(i=0; itotNum; i+) j=(xxi1); if(j%2) /如果 j 是奇数 totCnt+; he+=xxi; totPjz=(double)he/totCnt; 解析 读取正数,统计个数,右移后为奇数的个数及平均值。 通过审题可以发现仅有一个不同点,即参与平均值计算的元素是数组 xxi右移一位之后为奇数的元素,参考答案的第 9 条语句。

展开阅读全文
相关资源
猜你喜欢
  • ANSI INCITS ISO IEC 18045-2008 Information technology Security techniques Methodology for IT security evaluation.pdf ANSI INCITS ISO IEC 18045-2008 Information technology Security techniques Methodology for IT security evaluation.pdf
  • ANSI INCITS ISO IEC 18050-2006 Information technology - Office equipment - Print quality attributes for machine readable Digital Postage Marks《信息技术.办公设备.机读数字邮政标记的打印质量特征》.pdf ANSI INCITS ISO IEC 18050-2006 Information technology - Office equipment - Print quality attributes for machine readable Digital Postage Marks《信息技术.办公设备.机读数字邮政标记的打印质量特征》.pdf
  • ANSI INCITS ISO IEC 18050-2006 Information technology Office equipment Print quality attributes for machine readable Digital Postage Marks.pdf ANSI INCITS ISO IEC 18050-2006 Information technology Office equipment Print quality attributes for machine readable Digital Postage Marks.pdf
  • ANSI INCITS ISO IEC 18092-2013 Information technology - Telecommunications and information exchange between systems - Near Field Communication - Interface and Protocol (NFCIP-1).pdf ANSI INCITS ISO IEC 18092-2013 Information technology - Telecommunications and information exchange between systems - Near Field Communication - Interface and Protocol (NFCIP-1).pdf
  • ANSI INCITS ISO IEC 18093-1999 Information technology Data interchange on 130 mm optical disk cartridges of type WORM (Write Once Read Many) using irreversible effects Capacity 5 2.pdf ANSI INCITS ISO IEC 18093-1999 Information technology Data interchange on 130 mm optical disk cartridges of type WORM (Write Once Read Many) using irreversible effects Capacity 5 2.pdf
  • ANSI INCITS ISO IEC 18809-2000 Information technology - 8 mm wide magnetic tape cartridge for information interchange - Helical scan recording AIT-1 with MIC format.pdf ANSI INCITS ISO IEC 18809-2000 Information technology - 8 mm wide magnetic tape cartridge for information interchange - Helical scan recording AIT-1 with MIC format.pdf
  • ANSI INCITS ISO IEC 18809-2000 Information Technology - 8 mm Wide Magnetic Tape Cartridge for Information Interchange - Helical Scan Recording AIT-1 with MIC Format《信息技术.信息交换用8mm宽盒.pdf ANSI INCITS ISO IEC 18809-2000 Information Technology - 8 mm Wide Magnetic Tape Cartridge for Information Interchange - Helical Scan Recording AIT-1 with MIC Format《信息技术.信息交换用8mm宽盒.pdf
  • ANSI INCITS ISO IEC 18810-2001 Information technology - 8 mm wide magnetic tape cartridge for information interchange - Helical scan recording AIT-2 with MIC format.pdf ANSI INCITS ISO IEC 18810-2001 Information technology - 8 mm wide magnetic tape cartridge for information interchange - Helical scan recording AIT-2 with MIC format.pdf
  • ANSI INCITS ISO IEC 18836-2001 Information technology 8 mm wide magnetic tape cartridge for information interchange Helical scan recording MammothTape-2 format (Adopted by INCITS).pdf ANSI INCITS ISO IEC 18836-2001 Information technology 8 mm wide magnetic tape cartridge for information interchange Helical scan recording MammothTape-2 format (Adopted by INCITS).pdf
  • 相关搜索

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

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