Option Compare Database
Option Explicit
Dim N(8) As Integer
Public Sub Calc()
Dim i As Integer
Dim t1 As Single
t1 = Timer
For i = 1 To 1000
N(0) = 5
N(1) = 1
N(2) = 3
N(3) = 7
N(4) = 9
N(5) = 2
N(6) = 4
N(7) = 6
N(8) = 8
P1379
Next i
Debug.Print Timer - t1
End Sub
Private Sub P1379(Optional x As Integer = 1)
Dim y As Integer
Dim tmp As Integer
If x = 4 Then
P2468
Exit Sub
Else
P1379 x + 1
For y = x + 1 To 4
tmp = N(x)
N(x) = N(y)
N(y) = tmp
P1379 x + 1
N(y) = N(x)
N(x) = tmp
Next y
End If
End Sub
Private Sub P2468(Optional x As Integer = 5)
Dim y As Integer
Dim tmp As Integer
If x = 8 Then
If Check Then
'Debug.Print N(1) & N(5) & N(2) & N(6) & N(0) & N(7) & N(3) & N(8) & N(4)
End If
Exit Sub
Else
P2468 x + 1
For y = x + 1 To 8
tmp = N(x)
N(x) = N(y)
N(y) = tmp
P2468 x + 1
N(y) = N(x)
N(x) = tmp
Next y
End If
End SubPrivate Function Check() As Boolean
If (N(1) + N(5) + N(2)) Mod 3 <> 0 Then Exit Function '3
If (N(2) * 10 + N(6)) Mod 4 <> 0 Then Exit Function '4
If (N(1) + N(5) + N(2) + N(6) + N(7)) Mod 3 <> 1 Then Exit Function '6
If (N(7) * 100 + N(3) * 10 + N(8)) Mod 8 <> 0 Then Exit Function '8
If CLng(N(1) & N(5) & N(2) & N(6) & 5 & N(7) & N(3)) Mod 7 <> 0 Then Exit Function '7
Check = True
End Function
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) | Powered by Discuz! X3.3 |