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

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

1、三级数据库技术机试-62 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知在文件 in.dat中存有若干个(个数200)四位非零整数,函数 readdat()读取这若干个整数并存入数组 xx中。请编制函数 calvflue(),其功能要求:求出该文件中共有多少个正整数 totnum;求这些数右移 16 位,产生的一系列新数中含至少一个完全平方数(某个整数的平方)的个数 totcnt,以及满足此条件的这些数(右移前的值)的算术平均值 totpjz,最后调用函数 writedat()把所求的结果输出到文件out.dat中。部分源程序已给出。

2、请勿改动主函数 main()、读数据函数 readdat()和输出数据函数 writedat()的内容。#includestdio.h#includeconio.h#define MAXNUM 200int xxMAXNUM;iht totnum=0;iht totcnt=0;double totpjz=0.0;int readdat(void);void writedat(void);void calvalue(void)void main ()int i;clrscr ();for (i=0; iif (readdat ()printf(“Cant open the data file i

3、n.dat!/007/n“);return;calvalue ();printf ( “totnum=%d/n“, totnum);printf ( “totcnt=%d/n“ , totcnt );printf ( “totpj z=%. 21f/n“, totpj z);writedat ();int readdat (void)FILE *fp;int i=0;if( (fp=fopen (“in.dar“, “r“) )=NULL) return 1;while ( ! feof (fp)fscanf (fp, “%d, “, fclose (fp);return 0;void wri

4、tedat (void)FILE *fp;fp=fopen ( “out. dar“, “w“ )fprint f ( fp, “%d/n%d/n%. 21 f/n“, totnum, totcnt, totpjz);fclose (fp);(分数:100.00)_三级数据库技术机试-62 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知在文件 in.dat中存有若干个(个数200)四位非零整数,函数 readdat()读取这若干个整数并存入数组 xx中。请编制函数 calvflue(),其功能要求:求出该文件中共有多少个正整数 totn

5、um;求这些数右移 16 位,产生的一系列新数中含至少一个完全平方数(某个整数的平方)的个数 totcnt,以及满足此条件的这些数(右移前的值)的算术平均值 totpjz,最后调用函数 writedat()把所求的结果输出到文件out.dat中。部分源程序已给出。请勿改动主函数 main()、读数据函数 readdat()和输出数据函数 writedat()的内容。#includestdio.h#includeconio.h#define MAXNUM 200int xxMAXNUM;iht totnum=0;iht totcnt=0;double totpjz=0.0;int readdat

6、void);void writedat(void);void calvalue(void)void main ()int i;clrscr ();for (i=0; iif (readdat ()printf(“Cant open the data file in.dat!/007/n“);return;calvalue ();printf ( “totnum=%d/n“, totnum);printf ( “totcnt=%d/n“ , totcnt );printf ( “totpj z=%. 21f/n“, totpj z);writedat ();int readdat (void)

7、FILE *fp;int i=0;if( (fp=fopen (“in.dar“, “r“) )=NULL) return 1;while ( ! feof (fp)fscanf (fp, “%d, “, fclose (fp);return 0;void writedat (void)FILE *fp;fp=fopen ( “out. dar“, “w“ )fprint f ( fp, “%d/n%d/n%. 21 f/n“, totnum, totcnt, totpjz);fclose (fp);(分数:100.00)_正确答案:(提示:类型:整数移位运算。关键点:(1)数据结束判断:分析

8、 main()和 readdat(),得到 xxi为有效数据的条件是 0=xxiMAXNUM 且xxi!=0。(2)移位运算:,注意运算符优先级。(3)完全平方数判断:可以开平方再平方与原数比较,也可以枚举出 10000以内所有四位完全平方数再查表,解答中采用第一种,需要加上头文件 mathh。解答:#include math.hvoid calvalue(void)int i, j, data, sqt;for(i=0;iMAXNUM;+)if(!xxi) break; /*数据结束*/if(xxi0) totnum+; /*计数*/for (j=1; j=6; j+) data=(xxi); /*移位*/sqt =(int) (sqrt ( (double) data) +0.5); /*求平方根并四舍五入取整*/if(sqt*sqt = data) /*完全平方数*/totcnt+;totpjz+=xxi; /*计数,求和*/break;totpjz/=totcnt;)解析:

展开阅读全文
相关资源
猜你喜欢
  • ASTM F2374-2017 Standard Practice for Design Manufacture Operation and Maintenance of Inflatable Amusement Devices《充气娱乐装置的设计、制造、操作和维护的标准实施规程》.pdf ASTM F2374-2017 Standard Practice for Design Manufacture Operation and Maintenance of Inflatable Amusement Devices《充气娱乐装置的设计、制造、操作和维护的标准实施规程》.pdf
  • ASTM F2375-2009 Standard Practice for Design Manufacture Installation and Testing of Climbing Nets and Netting Mesh used in Amusement Rides Devices Play Areas and Attractions《用于机动游.pdf ASTM F2375-2009 Standard Practice for Design Manufacture Installation and Testing of Climbing Nets and Netting Mesh used in Amusement Rides Devices Play Areas and Attractions《用于机动游.pdf
  • ASTM F2375-2009(2017) Standard Practice for Design Manufacture Installation and Testing of Climbing Nets and Netting Mesh used in Amusement Rides Devices Play Areas and Attractions.pdf ASTM F2375-2009(2017) Standard Practice for Design Manufacture Installation and Testing of Climbing Nets and Netting Mesh used in Amusement Rides Devices Play Areas and Attractions.pdf
  • ASTM F2376-2006 Standard Practice for Classification Design Manufacture Construction and Operation of Water Slide Systems《水滑道的分类、设计、制造、结构和使用的标准实施规程》.pdf ASTM F2376-2006 Standard Practice for Classification Design Manufacture Construction and Operation of Water Slide Systems《水滑道的分类、设计、制造、结构和使用的标准实施规程》.pdf
  • ASTM F2376-2008 Standard Practice for Classification Design Manufacture Construction and Operation of Water Slide Systems《水滑道的分类 设计 制造 结构和使用的标准实施规程》.pdf ASTM F2376-2008 Standard Practice for Classification Design Manufacture Construction and Operation of Water Slide Systems《水滑道的分类 设计 制造 结构和使用的标准实施规程》.pdf
  • ASTM F2376-2013 Standard Practice for Classification Design Manufacture Construction and Operation of Water Slide Systems《水滑道系统的分类 设计 制造 建造和操作的标准实施规程》.pdf ASTM F2376-2013 Standard Practice for Classification Design Manufacture Construction and Operation of Water Slide Systems《水滑道系统的分类 设计 制造 建造和操作的标准实施规程》.pdf
  • ASTM F2376-2017 Standard Practice for Classification Design Manufacture Construction and Operation of Water Slide Systems.pdf ASTM F2376-2017 Standard Practice for Classification Design Manufacture Construction and Operation of Water Slide Systems.pdf
  • ASTM F2376-2017a Standard Practice for Classification Design Manufacture Construction and Operation of Water Slide Systems《水滑道的分类 设计 制造 建造以及操作的标准实施规程》.pdf ASTM F2376-2017a Standard Practice for Classification Design Manufacture Construction and Operation of Water Slide Systems《水滑道的分类 设计 制造 建造以及操作的标准实施规程》.pdf
  • ASTM F2378-2005 Standard Test Method for Sealability of Sheet Composite and Solid Form-in-Place Gasket Materials《复合薄板材和固态现场成型衬垫材料的密封能力的标准试验方法》.pdf ASTM F2378-2005 Standard Test Method for Sealability of Sheet Composite and Solid Form-in-Place Gasket Materials《复合薄板材和固态现场成型衬垫材料的密封能力的标准试验方法》.pdf
  • 相关搜索

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

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