Stringpermutationen von ???
Programm zur Aflistung aller n! Rekursionen von n Elementen (in einem String).
[code:1:92a8508422]permutate("1234",1)

Function SwapChars$(list$,pos1,pos2)
Local char1$,char2$,z
If pos1>pos2 Then
z = pos1
pos1 = pos2
pos2 = z
EndIf
If pos1<>pos2 Then
char1$ = Mid$(list$,pos1,1)
char2$ = Mid$(list$,pos2,1)
list$ = Left$(list$,pos1-1)+char2$+Mid$(list$,pos1+1,pos2-pos1-1)+char1$+Right$(list$,Len(list$)-pos2)
EndIf
Return list$
End Function

Function Permutate(list$,pos)
Local i
If pos=Len(list$)
Print list$
Else
For i=pos To Len(list$)
Permutate(swapchars$(list$,i,pos),pos+1)
Next
EndIf
End Function[/code:1:92a8508422]



Suche:
(unterstützt mySQL Wildcards ala %)
Titel:
Text:
Autor: