fyer 发表于 2003-3-16 22:14:00

知道这个code最后算出什么来?

Sub Calc()
    Dim cAs Long, j As Long, k As Long, p As Single
    Dim a As Single
    Dim b As Single
   
    c = Val(InputBox("")) 'If c is large enough...
   
    For j = 1 To c
      a = Rnd
      b = Rnd
      If a ^ 2 + b ^ 2 <= 1 Then k = k + 1
    Next j
   
    p = k / j * 4 'What p is...
End Sub

fyer 发表于 2003-3-16 22:15:00

哈哈,这个算法算pi值效率太低了。
页: [1]
查看完整版本: 知道这个code最后算出什么来?