C#模拟圆周率的算法
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 圆周率
{
class Program
{
static void Main(string[] args)
{
double count = 0;
var n = 1000;
for (double i = 1; i < n; i++)
{
count += 1 / (i * i);
}
var pi = Math.Pow(count * 6, 0.5);
Console.WriteLine(pi);
Console.ReadKey();
}
}
}
文章来源:www.900544.com
浙公网安备 33010602011771号