舍入误差与有效数.docVIP

  • 20
  • 0
  • 约1.18千字
  • 约 2页
  • 2020-10-01 发布于北京
  • 举报
舍入误差与有效数 设,其精确值为。 (1)编制按从小到大的顺序,计算的通用程序。 (2)编制按从大到小的顺序,计算的通用程序。 (3)按两种顺序分别计算,并指出有效位数。(编制程序时用单精度) ――――――――――――――――――――――――――――――――――――――― c++代码:(在visual C++ 6.0中编译通过) #include iostream.h #include fstream.h void main(){ float S1,S2,S=0.0,N,j; fstream myfile; //定义文件 myfile.open(chap0.txt,ios::in|ios::out); for (int i=0;i3;i++) { do //读入三组数据 { cout请输入N值:; cinN; coutendl; myfile当N = N 时endlendl; }while (N2); S=(float) ((1.5-(1.0/N)-(1.0/(N+1)))/2); myfile精确值S=:Sendlendl; S1=0.0;S2=0.0; for (j=2;j=N;j++) S1=S1+(float)

文档评论(0)

1亿VIP精品文档

相关文档