Public r As Long Sub peng() aa = Timer Dim jj As Long, cc As Long arr = Range("A1:A" & [A65536].End(xlUp).Row) Call xi("", arr, 1, 0, Cells(1, 2), jj) MsgBox "找到 " & jj & " 个解! 花费" & Format(Timer - aa, "0.00" & "保存在C列") & "秒" End Sub Sub xi(a, arr, x As Long, y As Long, z As Long, jj As Long) If y = z Then jj = jj + 1 r = r + 1 Cells(r, 3) = a Exit Sub End If If x = UBound(arr) + 1 Then Exit Sub If y + UBound(arr) - x + 1 < z Then Exit Sub Call xi(a & " " & arr(x, 1), arr, x + 1, y + 1, z, jj) '字附串和数字的处理速度是相差很大的 Call xi(a, arr, x + 1, y, z, jj) End Sub
|