08/06/05 10:33:50
URLリンク(kansai2channeler.hp.infoseek.co.jp)
buffonの針のシミュレーションでπを求めるプログラムなんですけど
Borland C++ Compilerでコンパイルすると
C:\borland\bcc55\src\C++>buffon.exe
Length of needle (0<L<=1): 1
Drop total of needle : 100
Number of hits = 55
Pi = 3.63636
という風にシミュレーション結果が出るんですが、
同じソースをcygwin g++(version4.2.4)でコンパイルすると
$ ./a.exe
Length of needle (<=1): 1
Drop total of needle : 100
Number of hits = 100
Pi = 2
という風におかしなシミュレーション結果になってしまうんですが、何が原因なんでしょうか?