[计算机类试卷]国家三级(数据库技术)机试模拟试卷41及答案与解析.doc

上传人:bonesoil321 文档编号:495315 上传时间:2018-11-28 格式:DOC 页数:2 大小:25.50KB
下载 相关 举报
[计算机类试卷]国家三级(数据库技术)机试模拟试卷41及答案与解析.doc_第1页
第1页 / 共2页
[计算机类试卷]国家三级(数据库技术)机试模拟试卷41及答案与解析.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家三级(数据库技术)机试模拟试卷 41及答案与解析 一、程序设计题 1 下列程序的功能是:利用以下所示的简单迭代方法求方程: cos(x)-x=0的一个实根。 xn+1=cos(xn) 迭代步骤如下: (1)取 x1初值为 0.0。 (2)x0=x1,把 x1的值赋给 x0。 (3)x1=cos(x0),求出一个新的 x1。 (4)若 x0-x1的绝对值小于 0.000001,执行步骤 (5),否则执行步骤 (2)。 (5)所求 x1就是方程 cos(x)-x=0的一个实根,作为函数值返回。 请编写函数 countValue()实现程序要求,最后调用函数 writeDAT()把结果输出到文件

2、 out41.dar中。 注意:部分源程序已给出。 请勿改动主函数 main()和写函数 writeDAT()的内容。 试题程序: #include conio.h #include math.h #include stdio.h float countvalue( ) main ( ) clrscr( ); printf(“实根 =%fn“,countValue( ); printf(“%fn“,cos(countValue( )countValue( ); writeDAT( ); writeDAT( ) FILE *wf; wf=fopen(“out41.dat“,“w“); fprin

3、tf(wf,“%fln“,countValue( fclose(wf); 国家三级(数据库技术)机试模拟试卷 41答案与解析 一、程序设计题 1 【正确答案】 float countValue() float x0, x1=0.0; while(1) x0=x1; /*将 x1赋值给 x0*/ x1=cos(x0); /*求出新的 x1*/ if(fabs(x0-x1) 1e-6)break; /*若 x0-x1的绝对值小于 0.000001,则结 束循环*/ return x1; 【试题解析】 本题考查的知识点如下: (1)数学函数 doublecos(doublex)及 doublefabs(doublex)的使用。 (2)使用循环结构实现迭代。 在本题中,因为要求一个实数的余弦值,在结束迭代的时候要判断绝对值,所以这里要用到数学函数 cos(doublex)和 fabs(doublex)。先设一个条件永远为真的while循环结构,按照步骤提示,要先为 x1取初值,将 x1的值赋给 x0,使xl=cos(x0), 判断 x0-x1的绝对值将其作为强行退出循环的条件。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 2702-2003 Aerospace Series Aluminium Alloy AL-P6061-T6 or T62 Extruded Bar and Section a or D Less Than or Equal to 150 mm Edition P 3《航空和航天系列铝合金AL-P6061-T6 or T62挤压棒材与型.pdf AECMA PREN 2702-2003 Aerospace Series Aluminium Alloy AL-P6061-T6 or T62 Extruded Bar and Section a or D Less Than or Equal to 150 mm Edition P 3《航空和航天系列铝合金AL-P6061-T6 or T62挤压棒材与型.pdf
  • AECMA PREN 2703-2003 Aerospace Series Aluminium Alloy AL-P2024-T4 or T42 Clad Sheet and Strip 0 3 mm Less Than or Equal to a Less Than or Equal to 6 mm Edition P 1《航空和航天系列铝合金AL-P20.pdf AECMA PREN 2703-2003 Aerospace Series Aluminium Alloy AL-P2024-T4 or T42 Clad Sheet and Strip 0 3 mm Less Than or Equal to a Less Than or Equal to 6 mm Edition P 1《航空和航天系列铝合金AL-P20.pdf
  • AECMA PREN 2704-1985 Aerospace Series Aluminium Alloy 2024-T3511 Drawn Bar a Less Than or Equal to 75 mm Edition 1《航空和航天系列铝合金 2024-T3511 冷拉棒材a小于或等于75mm》.pdf AECMA PREN 2704-1985 Aerospace Series Aluminium Alloy 2024-T3511 Drawn Bar a Less Than or Equal to 75 mm Edition 1《航空和航天系列铝合金 2024-T3511 冷拉棒材a小于或等于75mm》.pdf
  • AECMA PREN 2705-1985 Aerospace Series Aluminium Alloy 2017A-T42 Drawn Tube for Structures 0 6 Less Than or Equal to a Less Than or Equal to 12 5 mm Edition 1《航空和航天系列铝合金 2017A-T42冷拉.pdf AECMA PREN 2705-1985 Aerospace Series Aluminium Alloy 2017A-T42 Drawn Tube for Structures 0 6 Less Than or Equal to a Less Than or Equal to 12 5 mm Edition 1《航空和航天系列铝合金 2017A-T42冷拉.pdf
  • AECMA PREN 2706-1985 Aerospace Series Aluminium Alloy 7009-T736510 Bar and Section 1 2 Less Than or Equal to (a or D) Less Than or Equal to 125 mm with Peripheral Coarse Grain Cont.pdf AECMA PREN 2706-1985 Aerospace Series Aluminium Alloy 7009-T736510 Bar and Section 1 2 Less Than or Equal to (a or D) Less Than or Equal to 125 mm with Peripheral Coarse Grain Cont.pdf
  • AECMA PREN 2707-1985 Aerospace Series Aluminium Alloy 7075-T6510 Bar and Section 1 2 Less Than or Equal to (a or D) Less Than or Equal to 125 mm with Peripheral Coarse Grain Contro.pdf AECMA PREN 2707-1985 Aerospace Series Aluminium Alloy 7075-T6510 Bar and Section 1 2 Less Than or Equal to (a or D) Less Than or Equal to 125 mm with Peripheral Coarse Grain Contro.pdf
  • AECMA PREN 2708-1985 Aerospace Series Aluminium Alloy 7075-T73510 Bar and Section 1 2 Less Than or Equal to (a or D) Less Than or Equal to 100 mm with Peripheral Coarse Grain Contr.pdf AECMA PREN 2708-1985 Aerospace Series Aluminium Alloy 7075-T73510 Bar and Section 1 2 Less Than or Equal to (a or D) Less Than or Equal to 100 mm with Peripheral Coarse Grain Contr.pdf
  • AECMA PREN 2709-1985 Aerospace Series Aluminium Alloy 2024-T3510 Bar and Section 1 2 Less Than or Equal to (a or D) less Than or Equal to 150 mm with Peripheral Coarse Grain Contro.pdf AECMA PREN 2709-1985 Aerospace Series Aluminium Alloy 2024-T3510 Bar and Section 1 2 Less Than or Equal to (a or D) less Than or Equal to 150 mm with Peripheral Coarse Grain Contro.pdf
  • AECMA PREN 2710-1985 Aerospace Series Aluminium Alloy 2014A-T4510 Bar and Section 1 2 Less Than or Equal to (a or D) Less Than or Equal to 200 mm with Peripheral Coarse Grain Contr.pdf AECMA PREN 2710-1985 Aerospace Series Aluminium Alloy 2014A-T4510 Bar and Section 1 2 Less Than or Equal to (a or D) Less Than or Equal to 200 mm with Peripheral Coarse Grain Contr.pdf
  • 相关搜索

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

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