大家看一下,这是我写的密码不断改变的程序,为什么p的值一直在变,却能够很快测出p的值.
Dim p, z As Long
Dim c(0 To 9, 0 To 9) As Byte
Private Sub Command1_Click()
a = 1
b = 1000000000
r = Int((a + b) / 2)
If a = p Then
Label1.Caption = a
ElseIf b = p Then
Label1.Caption = b
Else
While r <> p
If r > p Then
b = r
Else
a = r
End If
r = Int((a + b) / 2)
Wend
Label1.Caption = r
End If
For i = 1 To 100000000
Next
If r = p Then
MsgBox ("you are right")
End If
End Sub
Private Sub Form_load()
Show
p = 123456789
q = p
m = 0
For i = 0 To 9
k = m
m = m + 1
For j = 0 To 9
c(i, j) = k
k = k + 1
If k > 9 Then
k = 0
End If
Next
Next
Timer1.Interval = 1
End Sub
Private Function try(ByVal x As Long)
Dim z As Long
Randomize
y = Int(Rnd * 10)
For i = 0 To 8
k = x Mod 10
z = c(y, k) * (10 ^ i) + z
x = x \ 10
Next i
try = z
End Function
Private Sub Timer1_Timer()
p = try(p)
End Sub