using System.Collections.Generic;
using System.Text;
* 利用循环迭代法求PI
* 直到最后一项的绝对值小于 10的-6次方为止。
*/
{
static void Main(string[] args)
{
{
double pi = 0;
double k = 0;
double i = 1;
int n = 1;
do
{
k = n / i;
pi += k;
i += 2;
n = -n;
} while (Math.Abs(k)>=1e-8);
return 4*pi;
}
}