#include <array.au3>
Dim $aArray[5] = ['苹果', '梨', '橘子', '香蕉', '西瓜']
Dim $x = 0, $Num = CombineNum(UBound($aArray))
Dim $aCombine[$Num]
Combine($aArray, 0, UBound($aArray) - 1)
_ArrayDisplay($aCombine)
Func Combine($aArray, $k, $m)
Local $i, $str = ''
If $k > $m Then
For $i = 0 To $m
$str &= $aArray[$i] & "|"
Next
$aCombine[$x] = StringTrimRight($str, 1)
$x += 1
Else
For $i = $k To $m
;~
_ArraySwap($aArray[$k], $aArray[$i])
;~
Combine($aArray, $k + 1, $m)
;~
_ArraySwap($aArray[$k], $aArray[$i])
;~ ========以上是老版本函数调用方式===============
;~ ========以下是新版本函数调用方式===============
_ArraySwap($aArray, $k, $i)
Combine($aArray, $k + 1, $m)
_ArraySwap($aArray, $k, $i)
Next
EndIf
EndFunc ;==>Combine
Func CombineNum($n = 0)
If $n > 1 Then
Return $n * CombineNum(($n - 1))
Else
Return $n
EndIf
EndFunc ;==>CombineNum
|