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

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

1、三级数据库技术-517 及答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.程序 test.c的功能是:利用以下所示的简单迭代方法求方程 cos(x)-x=0的一个实根。 迭代公式:x n+1 =cos(x n )(n是迭代次数) 迭代步骤如下: (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的一个实根,作为函数值返回。 请编

2、写函数 countValue()实现程序的功能,最后 main()函数调用函数 writeDAT()把结果输出到文件out.dat中。 请勿改动主函数 main()和输出数据函数 writeDAT()的内容。 #include math.h /表示这个程序中要引用 vc6.0的数学库函数 #include stdio.h /表示这个程序要引用 vc6.0的标准输入输出函数 void writeDAT(); /writeDAT()函数的说明语句 double countValue() main () printf (“实根=%fn“, countValue (); /在屏幕上显示方程的一个实根

3、printf (“ %fn“, cos (countValue () -countValue (); /在屏幕显示求得这个实根的精度 writeDAT (); /把结果输出到文件 out.dat中 / *函数 writeDAT()把结果输出到文件 out.dat中* / void writeDAT() FILE *wf; /定义文件指针变量 wf wf=fopen ( “out.dat“, “w“ ); /以只写的方式打开 out.dat,并使 wf指向这个文件 fprintf(wf, “%fkn“, countValue(); /把求得的实根写入到文件 out.dat fclose (wf)

4、 /关闭文件 out.dat (分数:100.00)_三级数据库技术-517 答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.程序 test.c的功能是:利用以下所示的简单迭代方法求方程 cos(x)-x=0的一个实根。 迭代公式:x n+1 =cos(x n )(n是迭代次数) 迭代步骤如下: (1)取 x1初值为 0.0; (2)x0=x1,把 x1的值赋给 x0; (3)x1=cos(x0),求出一个新的 x1; (4)若 x0-x1的绝对值小于 0.000001,执行步骤(5),否则执行步骤(2); (5)所求 x1就是方程

5、cos(x)-x=0的一个实根,作为函数值返回。 请编写函数 countValue()实现程序的功能,最后 main()函数调用函数 writeDAT()把结果输出到文件out.dat中。 请勿改动主函数 main()和输出数据函数 writeDAT()的内容。 #include math.h /表示这个程序中要引用 vc6.0的数学库函数 #include stdio.h /表示这个程序要引用 vc6.0的标准输入输出函数 void writeDAT(); /writeDAT()函数的说明语句 double countValue() main () printf (“实根=%fn“, cou

6、ntValue (); /在屏幕上显示方程的一个实根 printf (“ %fn“, cos (countValue () -countValue (); /在屏幕显示求得这个实根的精度 writeDAT (); /把结果输出到文件 out.dat中 / *函数 writeDAT()把结果输出到文件 out.dat中* / void writeDAT() FILE *wf; /定义文件指针变量 wf wf=fopen ( “out.dat“, “w“ ); /以只写的方式打开 out.dat,并使 wf指向这个文件 fprintf(wf, “%fkn“, countValue(); /把求得的

7、实根写入到文件 out.dat fclose (wf); /关闭文件 out.dat (分数:100.00)_正确答案:()解析:double x1,x1=0.0; /定义双精度型变量 x0,x1,变量 x1赋初值为 0.0 while(1) /执行 while循环语句 x0=x1; /把 x1的值赋给 x0 x1=cos(x0); /求出一个新的 x1 if(fabs(x0-x1)0.000001) /如果 x0-x1的绝对值小于 0.000001,则退出循环 break; /退出循环 return x1; /此时 x1的值就是方程的一个实根 解析 Xn+1=cos(Xn)的迭代计算。 因为方程 cos(x)-x=0的根为实数,所以定义两个双精度型变量 x0,x1。并把变量 x1的初值设为 0.0。 根据题目中给出的求方程一个实根的迭代算法,在 while循环中,首先把变量 x1的值赋给 x0,然后利用表达式 cos(x0)求出一个值 x1,再调用 vc6.0的求绝对值的库函数 fabs(),判断如果 x0与 x1差的绝对值小于 0.000001,就认为 x1的值是方程 cos(x)-x=0的一个实根,此时退出循环,把 x1的值返回。

展开阅读全文
相关资源
猜你喜欢
  • BS EN 4111-2006 Wrenches splined sockets for pipe fittings - Technical specification《航空航天系列 管件的花键套筒扳手 技术规范》.pdf BS EN 4111-2006 Wrenches splined sockets for pipe fittings - Technical specification《航空航天系列 管件的花键套筒扳手 技术规范》.pdf
  • BS EN 4113-2009 Aerospace series - Clamps loop ( P  type) in corrosion resisting steel passivated with rubber cushioning - Dimensions masses《航空航天系列 带橡胶弹性衬料的耐腐蚀钝化的钢制环形(P型)卡箍 尺寸和质量》.pdf BS EN 4113-2009 Aerospace series - Clamps loop ( P type) in corrosion resisting steel passivated with rubber cushioning - Dimensions masses《航空航天系列 带橡胶弹性衬料的耐腐蚀钝化的钢制环形(P型)卡箍 尺寸和质量》.pdf
  • BS EN 4114-2009 Aerospace series - Clamps loop (P type) in aluminium alloy with rubber cushioning - Dimensions masses《航空航天系列 带橡胶衬料的铝合金环形卡箍( P 型) 尺寸、质量》.pdf BS EN 4114-2009 Aerospace series - Clamps loop (P type) in aluminium alloy with rubber cushioning - Dimensions masses《航空航天系列 带橡胶衬料的铝合金环形卡箍( P 型) 尺寸、质量》.pdf
  • BS EN 4115-2010 Aerospace series - Cushion rubber for clamps - Dimensions masses《航空航天系列 夹紧用橡胶垫 尺寸规格 质量》.pdf BS EN 4115-2010 Aerospace series - Cushion rubber for clamps - Dimensions masses《航空航天系列 夹紧用橡胶垫 尺寸规格 质量》.pdf
  • BS EN 4116-2004 Aerospace series - Nuts hexagonal self-locking in heat resisting steel FE-PA2601 (A286) silver plated on thread - Classification - 1 100 MPa (at ambient temperature.pdf BS EN 4116-2004 Aerospace series - Nuts hexagonal self-locking in heat resisting steel FE-PA2601 (A286) silver plated on thread - Classification - 1 100 MPa (at ambient temperature.pdf
  • BS EN 4117-2004 Aerospace series - Nuts bihexagonal self-locking in heat resisting nickel base alloy NI-PH2601 (Inconel 718) silver plated on thread - Classification - 1 550 MPa (a.pdf BS EN 4117-2004 Aerospace series - Nuts bihexagonal self-locking in heat resisting nickel base alloy NI-PH2601 (Inconel 718) silver plated on thread - Classification - 1 550 MPa (a.pdf
  • BS EN 4118-2004 Aerospace series - Nuts bihexagonal self-locking in heat resisting steel FE-PA2601 (A286) silver plated on thread - Classification - 1 100 MPa (at ambient temperatu.pdf BS EN 4118-2004 Aerospace series - Nuts bihexagonal self-locking in heat resisting steel FE-PA2601 (A286) silver plated on thread - Classification - 1 100 MPa (at ambient temperatu.pdf
  • BS EN 4119-2004 Aerospace series - Nuts bihexagonal self-locking deep counterbore in heat resisting steel FE-PA2601 (A286) silver plated on thread - Classification - 1 100 MPa (at .pdf BS EN 4119-2004 Aerospace series - Nuts bihexagonal self-locking deep counterbore in heat resisting steel FE-PA2601 (A286) silver plated on thread - Classification - 1 100 MPa (at .pdf
  • BS EN 4120-2004 Nuts bihexagonal self-locking in heat resisting nickel base alloy NI-PH1302 (Waspaloy) silver plated on thread - Classification - 1 210 MPa (at ambient temperature).pdf BS EN 4120-2004 Nuts bihexagonal self-locking in heat resisting nickel base alloy NI-PH1302 (Waspaloy) silver plated on thread - Classification - 1 210 MPa (at ambient temperature).pdf
  • 相关搜索

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

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