⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class1.cs

📁 c#的学习资料 书上的东西 很难找到的啊
💻 CS
字号:
using System;
//using System.Threading;

namespace CalcPi
{
	///	<summary>
	///	Summary	description	for	Class1.
	///	</summary>
	class Class1
	{
		static void	Main(string[] args)
		{
			const int throws = 10000000;
			DateTime now = DateTime.Now;
			Random rand	= new Random ((int)	now.Millisecond);
			int	Inside = 0;
			for	(int i = 0;	i <	throws;	++i)
			{
				double cx =	rand.NextDouble();
				double cy =	rand.NextDouble();
				double distance	= Math.Sqrt	((cx * cx) + (cy * cy));
				if (distance < 1.0)
					++Inside;
			}
			double pi =	4 *	(double) Inside	/ (double) throws;
			DateTime End = DateTime.Now;
			TimeSpan Diff =	End	- now;
			Console.WriteLine ("pi = " + pi);
			Console.WriteLine ("Milliseconds = " + Diff.TotalMilliseconds);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -