0.97497 +/- 0.00001

來源: 2011-02-14 13:09:38 [博客] [舊帖] [給我悄悄話] 本文已被閱讀:

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