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

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

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

2、数据,主函数 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; i+) xxi=0; if(Read

3、Dat() printf(“数据文件 in.dat不能打开!007n“); return; CaiValue(); 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; while(!feof(fp) fsc

4、anf(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)_三级数据库技术-503 答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.已知在 in.dat中存有若干个(个数200)四位数字的正整数,函数 ReaaDa

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

6、Num=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; CaiValue(); printf(“文件 in.dat中共有正整数=%d 个n“, totNum); printf(“

7、符合条件的正整数的个数:%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中*/ void WriteDat(void) FILE *fp; fp=fopen(“out.da

8、t“, “w“); fprintf(fp, “%dn%dn%.2lfn“, totNum, totCnt, totPjz); fclose(fp); (分数:100.00)_正确答案:()解析:int i, j; long he=0; char num5; for(i=0; i5; i+) numi=0; for(i=0; iMAXNUM; i+) if(xxi) totNum+; for(i=0; itotNum; i+) sprintf(num, “%04d“, xxi); j=num0-48+num1-48+num2-48+num3=48; if(j%2) /如果 xxi的各位数字之和是奇数 ( totCnt+j he+=xxi; totPjz=(double)he/totCnt; 解析 读取正数,统计个数,各位数之和为奇数的数的个数及平均值。 通过审题可以发现仅有一个不同点,即四位数的各位数之和为奇数,参考答案的第 13条语句,将该该语句为判断各位数字之和是奇数的表达式即可。

展开阅读全文
相关资源
猜你喜欢
  • ASTM D5591-2004(2016) Standard Test Method for Thermal Shrinkage Force of Yarn and Cord With a Thermal Shrinkage Force Tester《利用热收缩力试验机测定纱线和绳索热收缩性的标准试验方法》.pdf ASTM D5591-2004(2016) Standard Test Method for Thermal Shrinkage Force of Yarn and Cord With a Thermal Shrinkage Force Tester《利用热收缩力试验机测定纱线和绳索热收缩性的标准试验方法》.pdf
  • ASTM D5592-1994(2002)e1 Standard Guide for Material Properties Needed in Engineering Design Using Plastics《使用塑料的工程设计中所要求的材料特性标准导则》.pdf ASTM D5592-1994(2002)e1 Standard Guide for Material Properties Needed in Engineering Design Using Plastics《使用塑料的工程设计中所要求的材料特性标准导则》.pdf
  • ASTM D5592-1994(2010) Standard Guide for Material Properties Needed in Engineering Design Using Plastics《使用塑料的工程设计中所要求的材料特性的标准指南》.pdf ASTM D5592-1994(2010) Standard Guide for Material Properties Needed in Engineering Design Using Plastics《使用塑料的工程设计中所要求的材料特性的标准指南》.pdf
  • ASTM D5592-1994(2018) Standard Guide for Material Properties Needed in Engineering Design Using Plastics《塑料工程设计所需材料性能的标准指南》.pdf ASTM D5592-1994(2018) Standard Guide for Material Properties Needed in Engineering Design Using Plastics《塑料工程设计所需材料性能的标准指南》.pdf
  • ASTM D5594-1998(2004) Standard Test Method for Determination of the Vinyl Acetate Content of Ethylene-Vinyl Acetate (EVA) Copolymers by Fourier Transform Infrared Spectroscopy (FT-.pdf ASTM D5594-1998(2004) Standard Test Method for Determination of the Vinyl Acetate Content of Ethylene-Vinyl Acetate (EVA) Copolymers by Fourier Transform Infrared Spectroscopy (FT-.pdf
  • ASTM D5594-1998(2012) Standard Test Method for Determination of the Vinyl Acetate Content of Ethylene-Vinyl Acetate (EVA) Copolymers by Fourier Transform Infrared Spectroscopy (FT-.pdf ASTM D5594-1998(2012) Standard Test Method for Determination of the Vinyl Acetate Content of Ethylene-Vinyl Acetate (EVA) Copolymers by Fourier Transform Infrared Spectroscopy (FT-.pdf
  • ASTM D5594-2018 Standard Test Method for Determination of the Vinyl Acetate Content of Ethylene-Vinyl Acetate (EVA) Copolymers by Fourier Transform Infrared Spectroscopy (FT-IR).pdf ASTM D5594-2018 Standard Test Method for Determination of the Vinyl Acetate Content of Ethylene-Vinyl Acetate (EVA) Copolymers by Fourier Transform Infrared Spectroscopy (FT-IR).pdf
  • ASTM D5596-2003 Standard Test Method for Microscopic Evaluation of the Dispersion of Carbon Black in Polyolefin Geosynthetics《聚烯烃土工合成织物中炭黑分散的显微镜评定标准试验法》.pdf ASTM D5596-2003 Standard Test Method for Microscopic Evaluation of the Dispersion of Carbon Black in Polyolefin Geosynthetics《聚烯烃土工合成织物中炭黑分散的显微镜评定标准试验法》.pdf
  • ASTM D5596-2003(2009) Standard Test Method for Microscopic Evaluation of the Dispersion of Carbon Black in Polyolefin Geosynthetics《聚烯烃土工合成织物中碳墨分散的显微镜评定标准试验法》.pdf ASTM D5596-2003(2009) Standard Test Method for Microscopic Evaluation of the Dispersion of Carbon Black in Polyolefin Geosynthetics《聚烯烃土工合成织物中碳墨分散的显微镜评定标准试验法》.pdf
  • 相关搜索

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

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