Public jj As Long, mx, mi, arr, arr3, n As Long Sub peng() arr = Cells(1, 1).Resize([a65536].End(xlUp).Row, 1) 'm n = [b1] 'n jj = 0 mx = 4190 '最大值 mi = 4150 '最小值 If n < 1 Then Exit Sub ReDim arr3(1 To 65536, 1 To n) ReDim arr2(1 To n + 1) As Long Call xi(1, j, x, arr2) Cells(1, 5).Resize(65536, n) = arr3 End Sub Sub xi(ii, j, x, arr2) If jj > 60000 Then Exit Sub If j = n + 1 Then Exit Sub If j > 1 And x > mi And x < mx Then jj = jj + 1 For i = 1 To j arr3(jj, i) = arr2(i) Next i Exit Sub '有可能是引起的 End If If ii + 1 > UBound(arr) Then Exit Sub If x + arr(ii, 1) < mx Then arr2(j + 1) = arr(ii, 1) xi ii + 1, j, x, arr2 End If If x + arr(ii, 1) < mx Then arr2(j + 1) = arr(ii, 1) xi ii + 1, j + 1, x + arr(ii, 1), arr2 End If End Sub 不好意思,我之过也,没有试一下就发给你了,中间变量用重了,所以导致了这个问题,已解决
[此贴子已经被作者于2008-7-8 17:50:45编辑过] |