|
我也用模拟,考虑过几种解析算法,都没有成功。
模拟程序如下:
Dim Toatl, Qualify As Double
Dim Hole(24) As Integer
Dim Card(8) As Integer
Dim P1, P2, P4 As Integer
Dim I1 As Integer
Randomize()
Dim Num As Double
P4 = 0
While (1)
For I1 = 0 To 24
Hole(I1) = 0
'清空各洞的球数
Next
I1 = 0
While I1 < 70
'70个球随机进洞
Num = Rnd()
P2 = Num * 27
If P2 > 0 And P2 < 26 Then
Hole(P2 - 1) = Hole(P2 - 1) + 1
I1 = I1 + 1
'确保完全随机,边界上的数字不要
End If
End While
P1 = 1
'首先认为每个洞都进了球
For I1 = 0 To 24
If Hole(I1) = 0 Then
P1 = 0
'这个洞没有球
Exit For
End If
Next
Toatl = Toatl + 1
Qualify = Qualify + P1
P4 = P4 + 1
If P4 = 200000 Then
TextBox1.Text = Qualify
TextBox2.Text = Toatl
TextBox3.Text = Format(Qualify / Toatl, "####.####%")
P4 = 0
Me.Refresh()
'显示结果
End If
End While
|
|