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

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

1、三级数据库技术机试-184 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.编写函数 jsValue,它的功能是:求 Hofstadter数列中的第 m项 H(m)(m1000),结果由函数返回。其中数列 H(n)的定义为:H(1)=H(2)=1H(n)=H(n-H(n-1)+H(n-H(n-2)(n2)最后调用函数 writeDat()读取 50个数据 m,分别得出结果且把结果输出到文件 out.dat中。例如:当 t=997时,函数值为 605。部分源程序已给出。请勿改动主函数 main()和写函数 writeDat()的内容。#inc

2、ludestdio. hint jsValue(int m)main ( )int m;m=300;printf (“m=%d, k-%d/n“, m, jsValue (m);writeDat ( );writeDat ( )FILE *in, *out;int i,m,s;in= fopen ( “in. dar“ , “r“ );out=f open ( “out. dar“ , “w“ );for (i=0; i50; i+) fscanf (in, “%d“, s=jsValue (m);printf( “%d/n“, s );fprintf (out, “%d/n“ , s );f

3、close (in);fclose (out);(分数:100.00)_三级数据库技术机试-184 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.编写函数 jsValue,它的功能是:求 Hofstadter数列中的第 m项 H(m)(m1000),结果由函数返回。其中数列 H(n)的定义为:H(1)=H(2)=1H(n)=H(n-H(n-1)+H(n-H(n-2)(n2)最后调用函数 writeDat()读取 50个数据 m,分别得出结果且把结果输出到文件 out.dat中。例如:当 t=997时,函数值为 605。部分源程序已给出。请勿

4、改动主函数 main()和写函数 writeDat()的内容。#includestdio. hint jsValue(int m)main ( )int m;m=300;printf (“m=%d, k-%d/n“, m, jsValue (m);writeDat ( );writeDat ( )FILE *in, *out;int i,m,s;in= fopen ( “in. dar“ , “r“ );out=f open ( “out. dar“ , “w“ );for (i=0; i50; i+) fscanf (in, “%d“, s=jsValue (m);printf( “%d/n

5、 s );fprintf (out, “%d/n“ , s );fclose (in);fclose (out);(分数:100.00)_正确答案:(提示:类型:序列计算。关键点:分析序列定义,选择合适的方法生成和存储序列或序列中的特定值。此题有两种解法:1按照定义编写递归函数;(计算量大,容易超时,慎用)。2保存所有值,从小到大递推求解。解答:/*解法一,递归*/int jsVelue(int m)if (m0)return -1;/*参数错误,正常运行不会出现*/if(m=1 | m=2)return 1;/*初值 H1:H2=1*/elsereturn jsValue (m-jsValue (m-1) +jsValue (m-jsValue (m-2);/*调用 jsValue递归计算 Hk*/*解法二,递推*/int jsValue(int m)int H1000, i;H1=1;H2=1;/*初值 H1=H2=1*/for (i=3;i=m;i+)Hi = Hi-Hi-1) +Hi-Hi-2;/*H(k)(ki)的值都己计算完成,直接使用*/return Hm;/*返回所求的值*/)解析:

展开阅读全文
相关资源
猜你喜欢
  • BS EN 13031-1-2002 Greenhouses - Design and construction - Commercial production greenhouses《温室 设计和建造 商品性生产用温室》.pdf BS EN 13031-1-2002 Greenhouses - Design and construction - Commercial production greenhouses《温室 设计和建造 商品性生产用温室》.pdf
  • BS EN 13032-3-2007 Measurement and presentation of photometric data of lamps and luminaires - Presentation of data for emergency lighting of work places《灯和灯具的光度数据的测量和表示 工作场所应急照明设备用.pdf BS EN 13032-3-2007 Measurement and presentation of photometric data of lamps and luminaires - Presentation of data for emergency lighting of work places《灯和灯具的光度数据的测量和表示 工作场所应急照明设备用.pdf
  • BS EN 13032-4-2015 Light and lighting Measurement and presentation of photometric data of lamps and luminaires LED lamps modules and luminaires《灯和照明 灯具和照明设备光度数据的测量和展示 LED灯具 模块和照明设备.pdf BS EN 13032-4-2015 Light and lighting Measurement and presentation of photometric data of lamps and luminaires LED lamps modules and luminaires《灯和照明 灯具和照明设备光度数据的测量和展示 LED灯具 模块和照明设备.pdf
  • BS EN 13034-2005+A1-2009 Protective clothing against liquid chemicals - Performance requirements for chemical protective clothing offering limited protective performance against li).pdf BS EN 13034-2005+A1-2009 Protective clothing against liquid chemicals - Performance requirements for chemical protective clothing offering limited protective performance against li).pdf
  • BS EN 13035-1-2008 Machines and plants for the manufacture treatment and processing of flat glass - Safety requirements - Part 1 Storage handling and ntransportation equipment insi.pdf BS EN 13035-1-2008 Machines and plants for the manufacture treatment and processing of flat glass - Safety requirements - Part 1 Storage handling and ntransportation equipment insi.pdf
  • BS EN 13035-2-2008 Machines and plants for the manufacture treatment and processing of flat glass - Safety requirements - Part 2 Storage handling and ntransportation equipment outs.pdf BS EN 13035-2-2008 Machines and plants for the manufacture treatment and processing of flat glass - Safety requirements - Part 2 Storage handling and ntransportation equipment outs.pdf
  • BS EN 13035-9-2006+A1-2010 Machines and plants for the manufacture treatment and processing of flat glass - Safety requirements - Washing installations《平面玻璃的制造、处理和加工用机械和设备 安全性要求 第9.pdf BS EN 13035-9-2006+A1-2010 Machines and plants for the manufacture treatment and processing of flat glass - Safety requirements - Washing installations《平面玻璃的制造、处理和加工用机械和设备 安全性要求 第9.pdf
  • BS EN 13036-1-2010 Road and airfield surface characteristics - Test methods - Measurement of pavement surface macrotexture depth using a volumetric patch technique《道路和机场表面特征 试验方法 使.pdf BS EN 13036-1-2010 Road and airfield surface characteristics - Test methods - Measurement of pavement surface macrotexture depth using a volumetric patch technique《道路和机场表面特征 试验方法 使.pdf
  • BS EN 13036-3-2002 Road and airfield surface characteristics - Test methods - Measurement of pavement surface horizontal drainability《道路和飞机场表面特征 试验方法 路面水平排水性的测量》.pdf BS EN 13036-3-2002 Road and airfield surface characteristics - Test methods - Measurement of pavement surface horizontal drainability《道路和飞机场表面特征 试验方法 路面水平排水性的测量》.pdf
  • 相关搜索

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

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