Non-recursive realization of unremnive sequences (1)

zhaozj2021-02-16  102

The author has written an example of using recursive achievement non-repeating sequence http://blog.9cbs.net/northwolves/archive/2004/04/07/19590.aspx

Now give another code utilizing the implementation of the implementation:

Sub pailie1 (ParamArray x ()) Dim starttime As Single, endtime As SingleDim n As Integer, i As Long, Num As Integer, j As IntegerDim temp1 () As String, temp2 As Long, all As New Collectionn = UBound (x) 1 'Element number StartTime = Timer' Start Timing Redim Temp1 (1 to N) for i = 0 to n ^ n - 1 Temp2 = ISET All = Nothingon Error ResMe Nextfor J = N to 1 Step -1Temp1 (J) = X (TEMP2 MOD N) 'Converts to N En-En-en-en-Idd Temp1 (j), TEMP1 (J)' Prevents Some elements from repeatting TEMP2 = Temp2 / nnextif all.count = n thendebug.print Join (TEMP1, " ") 'Output NUM = NUM ​​ 1END IF? DoeventsNextendtime = TimerDebug.print" A total of "& num" is arranged! "& Endtime - starttime &" second! "End Sub

PRIVATE SUB Command1_Click () pailie1 "a", "b", "c", "d", "e", "f", "g" end sub

转载请注明原文地址:https://www.9cbs.com/read-14537.html

New Post(0)