知道这个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 哈哈,这个算法算pi值效率太低了。
页:
[1]