Function Unequal(ParamArray Nums() As Variant) As Integer
Dim intI1 As Integer, intI2 As Integer, l As Integer, u As Integer
l = LBound(Nums())
u = UBound(Nums())
If u - l < 1 Then
Unequal = 3
Exit Function
End If
For intI1 = l To u - 1
For intI2 = intI1 + 1 To u
If Nums(intI1) = Nums(intI2) Then
Unequal = 0
Exit Function
End If
Next
Next
Unequal = 1
End Function
Sub hexagonhive ()
For a = 1 To 16
For b = 1 To 16
For c = 1 To 16
For d = 1 To 16
For e = 1 To 16
For f = 1 To 16
g = 49 - a - b - c - d - e – f
Dim ue As Integer, str As String
ue = Unequal(a, b, c, d, e, f, g)
If ue = 1 And g > 0 And g < 17 And 2 * b + c + 2 * d + e + 2 * f + g = 87 Then
t = t + 1
Cells(t, 1) = a: Cells(t, 2) = b: Cells(t, 3) = c: Cells(t, 4) = d: Cells(t, 5) = e: Cells(t, 6) = f: Cells(t, 7) = g:
End If
Next f, e, d, c, b, a
End Sub作者: stillfish00 時間: 2013-1-30 15:36