【计算机类职业资格】三级数据库技术-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条语句,将该该语句为判断各位数字之和是奇数的表达式即可。

展开阅读全文
相关资源
猜你喜欢
  • ITU-T T 851-2005 ITU-T T 81 (JPEG-1)-based still-image coding using an alternative arithmetic coder SERIES T TERMINALS FOR TELEMATIC SERVICES《使用可选算术编码器基于ITU-T T 81(JPEG-1)的静止图像编码扩展.pdf ITU-T T 851-2005 ITU-T T 81 (JPEG-1)-based still-image coding using an alternative arithmetic coder SERIES T TERMINALS FOR TELEMATIC SERVICES《使用可选算术编码器基于ITU-T T 81(JPEG-1)的静止图像编码扩展.pdf
  • ITU-T T 86 AMD 1-2012 Information technology C Digital compression and coding of continuous-tone still images Registration of JPEG Profiles SPIFF Profiles SPIFF Tags SPIFF colour S.pdf ITU-T T 86 AMD 1-2012 Information technology C Digital compression and coding of continuous-tone still images Registration of JPEG Profiles SPIFF Profiles SPIFF Tags SPIFF colour S.pdf
  • ITU-T T 86 FRENCH-1998 Information technology C Digital compression and coding of continuous-tone still images Registration of JPEG Profiles SPIFF Profiles SPIFF Tags SPIFF colour .pdf ITU-T T 86 FRENCH-1998 Information technology C Digital compression and coding of continuous-tone still images Registration of JPEG Profiles SPIFF Profiles SPIFF Tags SPIFF colour .pdf
  • ITU-T T 86 SPANISH-1998 Information technology C Digital compression and coding of continuous-tone still images Registration of JPEG Profiles SPIFF Profiles SPIFF Tags SPIFF colour.pdf ITU-T T 86 SPANISH-1998 Information technology C Digital compression and coding of continuous-tone still images Registration of JPEG Profiles SPIFF Profiles SPIFF Tags SPIFF colour.pdf
  • ITU-T T 86-1998 Information Technology - Digital Compression and Coding of Continuous-Tone Still Images Registration of JPEG Profiles SPIFF Profiles SPIFF Tags SPIFF Colour Spaces .pdf ITU-T T 86-1998 Information Technology - Digital Compression and Coding of Continuous-Tone Still Images Registration of JPEG Profiles SPIFF Profiles SPIFF Tags SPIFF Colour Spaces .pdf
  • ITU-T T 87-1998 Information Technology - Lossless and Near-Lossless Compression of Continuous-Tone Still Images - Baseline - Series T Terminals for Telematic Services《信息技术 连续色调静止图像.pdf ITU-T T 87-1998 Information Technology - Lossless and Near-Lossless Compression of Continuous-Tone Still Images - Baseline - Series T Terminals for Telematic Services《信息技术 连续色调静止图像.pdf
  • ITU-T T 870 FRENCH-2002 Information technology C Lossless and near-lossless compression of continuous-tone still images Extensions《信息技术 连续影调静态图像的无损及近无损压缩 扩展 16号研究组》.pdf ITU-T T 870 FRENCH-2002 Information technology C Lossless and near-lossless compression of continuous-tone still images Extensions《信息技术 连续影调静态图像的无损及近无损压缩 扩展 16号研究组》.pdf
  • ITU-T T 870 SPANISH-2002 Information technology C Lossless and near-lossless compression of continuous-tone still images Extensions《信息技术 连续影调静态图像的无损及近无损压缩 扩展 16号研究组》.pdf ITU-T T 870 SPANISH-2002 Information technology C Lossless and near-lossless compression of continuous-tone still images Extensions《信息技术 连续影调静态图像的无损及近无损压缩 扩展 16号研究组》.pdf
  • ITU-T T 870-2002 Information technology C Lossless and near-lossless compression of continuous-tone still images Extensions (Study Group 16)《信息技术 连续影调静态图像的无损及近无损压缩 扩展 16号研究组》.pdf ITU-T T 870-2002 Information technology C Lossless and near-lossless compression of continuous-tone still images Extensions (Study Group 16)《信息技术 连续影调静态图像的无损及近无损压缩 扩展 16号研究组》.pdf
  • 相关搜索

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

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