ch4_5.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:0k
源码类别:

C#编程

开发平台:

Visual C++

  1. //*********************
  2. //**    ch4_5.cpp    **
  3. //*********************
  4. #include <iostream.h>
  5. #include <math.h>
  6. void main()
  7. {
  8.   double s=0,x=1;   //初始值
  9.   for(int n=1; fabs(x)>1e-8; n++,x*=(-1.0)*(2*n-3)/(2*n-1))
  10.     s += x;
  11.   s*=4;   //π值
  12.   cout <<"the pi is " <<s <<endl;  //输出
  13. }