文学城论坛
+A-

0.97497 +/- 0.00001

布衣之才 2011-02-14 13:09:38 ( reads)

Set hits = 0

iterations:

{

Randomly pick four numbers x1, y1, x2, y2 between 0 and 1

if (x2-x1)^2 + (y2-y1)^2 > 1,  increment hits by 1

}

probability = hits / iterations

 

跟帖(1)

Blue_Diamond

2011-02-14 23:50:20

你的答案够准确了.精确答案:Pi-13/6=0.974925986