【计算机类职业资格】三级数据库技术机试-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;)解析:

展开阅读全文
相关资源
猜你喜欢
  • NF E48-676-1986 Hydraulic fluid power Filters Statement of requirements 《液压流体动力 过滤器 要求说明》.pdf NF E48-676-1986 Hydraulic fluid power Filters Statement of requirements 《液压流体动力 过滤器 要求说明》.pdf
  • NF E48-678-1995 Hydraulic fluid power Filters for receiver venting and pressurization Performances 《液压流体动力 接收器通风和增压用过滤器 性能》.pdf NF E48-678-1995 Hydraulic fluid power Filters for receiver venting and pressurization Performances 《液压流体动力 接收器通风和增压用过滤器 性能》.pdf
  • NF E48-679-1990 Hydraulic fluid power Filter elements Determination of absolute filtration rating 《液压流体动力 过滤器 绝对过滤额定值的测定》.pdf NF E48-679-1990 Hydraulic fluid power Filter elements Determination of absolute filtration rating 《液压流体动力 过滤器 绝对过滤额定值的测定》.pdf
  • NF E48-690-1990 Hydraulic fluid power Fluids Measurement of filtrability of mineral oils 《液压流体动力 流体 矿物油可过滤性的测定》.pdf NF E48-690-1990 Hydraulic fluid power Fluids Measurement of filtrability of mineral oils 《液压流体动力 流体 矿物油可过滤性的测定》.pdf
  • NF E48-692-1997 Hydraulic fluid power Fluids Measurement of filtrability of HFC and HFD class fire resistant fluids 《液压流体动力 流体 HFC 和 HFD 类防火流体的可过滤性测量》.pdf NF E48-692-1997 Hydraulic fluid power Fluids Measurement of filtrability of HFC and HFD class fire resistant fluids 《液压流体动力 流体 HFC 和 HFD 类防火流体的可过滤性测量》.pdf
  • NF E48-695-2003 Hydraulic fluid power - Parts and components - Expression of particulate pollution measurement results 《液压流体动力 零部件 颗粒污染测量结果的表示》.pdf NF E48-695-2003 Hydraulic fluid power - Parts and components - Expression of particulate pollution measurement results 《液压流体动力 零部件 颗粒污染测量结果的表示》.pdf
  • NF E48-701-1993 Hydraulic fluid power Filters Definitions nominal pressures nominal sizes fitting dimensions 《液压流体动力 过滤器 定义、公称压力、公称尺寸、配件尺寸》.pdf NF E48-701-1993 Hydraulic fluid power Filters Definitions nominal pressures nominal sizes fitting dimensions 《液压流体动力 过滤器 定义、公称压力、公称尺寸、配件尺寸》.pdf
  • NF E48-702-1993 Hydraulic fluid power Filter elements and filter housings Characteristics requirements 《液压流体动力 过滤器元件和过滤器壳体 特性和要求》.pdf NF E48-702-1993 Hydraulic fluid power Filter elements and filter housings Characteristics requirements 《液压流体动力 过滤器元件和过滤器壳体 特性和要求》.pdf
  • NF E48-703-1993 Hydraulic fluid power Filtr elements for inline filters Dimensions 《液压流体动力 串联过滤器的过滤元件 尺寸》.pdf NF E48-703-1993 Hydraulic fluid power Filtr elements for inline filters Dimensions 《液压流体动力 串联过滤器的过滤元件 尺寸》.pdf
  • 相关搜索

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

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