#include <Array.au3>
Local $sVar = "AB-CD-EF-GH-IJ-KL"
Local $sResult = $sVar & @CR
Local $aVar = StringSplit($sVar, "-")
For $i = 1 to $aVar[0]
_StringRepermutation($sVar, $sResult, $i)
Next
$aVar = StringSplit(StringTrimRight($sResult, 1), @CR, 1)
_Arraydisplay($aVar)
Func _StringRepermutation($sString, ByRef $sResult, $iComponents)
Local $sVar, $aVar
$aVar = StringSplit($sString, "-")
For $i = 1 To $iComponents
$sVar &= StringRight($aVar[$i], 1) & StringLeft($aVar[$i], 1) & "-"
Next
If ($iComponents < $aVar[0]) Then
$sVar &= StringRight($sString, ($aVar[0] * 3 - 1) - $iComponents * 3) & "-"
EndIf
$sVar = StringTrimRight($sVar, 1)
For $i = $iComponents + 1 To $aVar[0]
_StringRepermutation($sVar, $sResult, $i)
Next
$sResult &= $sVar & @CR
EndFunc ;==>_StringRepermutation
练练手,效率比afan兄的代码低下,用了递归的缘故。 |