[计算机类试卷]国家三级信息管理技术机试模拟试卷41及答案与解析.doc

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

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.dat中。 注意;部分源程序已给出。 请勿改动主函数 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“); fpri

3、ntf(wf,“%fn“,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)数学函数 double cos(double x)及 double fabs(double x)的使用。 (2)使用循环结构实现迭代。 在本题中,因为要求一个实数的余弦值,在结束迭代的时候要判断绝对值,所以这里要用到数学函数 cos(double x)和 fabs(double x)。先 设一个条件永远为真的while循环结构,按照步骤提示,要先为 x1取初值,将 x1的值赋给 x0,使x1=cos(x0),判断 x0-x1的绝对值将其作为强行退出循环的条件。

展开阅读全文
相关资源
猜你喜欢
  • AS NZS 4257 4-1994 Plastic roof and wall cladding materials - Methods of test - Determination of diffuse light transmission《塑料屋顶和墙面覆盖层材料 测试方法 漫射光透光率的测定》.pdf AS NZS 4257 4-1994 Plastic roof and wall cladding materials - Methods of test - Determination of diffuse light transmission《塑料屋顶和墙面覆盖层材料 测试方法 漫射光透光率的测定》.pdf
  • AS NZS 4257 5-1994 Plastic roof and wall cladding materials - Methods of test - Determination of glass fibre content《塑料屋顶和墙面覆盖层材料 测试方法 玻璃纤维含量的测定》.pdf AS NZS 4257 5-1994 Plastic roof and wall cladding materials - Methods of test - Determination of glass fibre content《塑料屋顶和墙面覆盖层材料 测试方法 玻璃纤维含量的测定》.pdf
  • AS NZS 4257 6-1994 Plastic roof and wall cladding materials - Methods of test - Determination of impact resistance《塑料屋顶和墙面覆盖层材料 测试方法 耐冲击性的测定》.pdf AS NZS 4257 6-1994 Plastic roof and wall cladding materials - Methods of test - Determination of impact resistance《塑料屋顶和墙面覆盖层材料 测试方法 耐冲击性的测定》.pdf
  • AS NZS 4257 7-1994 Plastic roof and wall cladding materials - Methods of test - Determination of colourfastness light transmission and impact resistance following ultraviolet light.pdf AS NZS 4257 7-1994 Plastic roof and wall cladding materials - Methods of test - Determination of colourfastness light transmission and impact resistance following ultraviolet light.pdf
  • AS NZS 4257 8-1994 Plastic roof and wall cladding materials - Methods of test - Determination of residual styrene《塑料屋顶和墙面覆盖层材料 测试方法 苯乙烯含量的测定》.pdf AS NZS 4257 8-1994 Plastic roof and wall cladding materials - Methods of test - Determination of residual styrene《塑料屋顶和墙面覆盖层材料 测试方法 苯乙烯含量的测定》.pdf
  • AS NZS 4257 9-1995 Plastic roof and wall cladding materials - Methods of test - Determination of transverse bending stiffness《塑料屋顶和墙面覆盖材料 测试方法 横向弯曲刚度的测定》.pdf AS NZS 4257 9-1995 Plastic roof and wall cladding materials - Methods of test - Determination of transverse bending stiffness《塑料屋顶和墙面覆盖材料 测试方法 横向弯曲刚度的测定》.pdf
  • AS NZS 4293-1995 International lamp coding system (ILCOS)《国际灯具编码系统(ILCOS)》.pdf AS NZS 4293-1995 International lamp coding system (ILCOS)《国际灯具编码系统(ILCOS)》.pdf
  • AS NZS 4327-1995 Metal-banded flexible couplings for low-pressure applications《低压应用带金属环的柔性管接头》.pdf AS NZS 4327-1995 Metal-banded flexible couplings for low-pressure applications《低压应用带金属环的柔性管接头》.pdf
  • AS NZS 4346-1995 Guide to the installation in vehicles of mobile communication equipment intended for connection to a cellular mobile telecommunication service (CMTS)《汽车上与蜂窝移动通信服务(.pdf AS NZS 4346-1995 Guide to the installation in vehicles of mobile communication equipment intended for connection to a cellular mobile telecommunication service (CMTS)《汽车上与蜂窝移动通信服务(.pdf
  • 相关搜索

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

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