#include <array.au3>
;首输入
Dim $aVarA[3] = ['a', 'b', 'c']
Dim $aVarB[3] = [1, 2, 3]
Dim $aVarC[3] = ['!', '@', '#']
Dim $aVarD[3] = ['$', '%', '^']
Dim $aVarE[3] = ['&', '*', '(']
Dim $arrar[5] = [$aVarA, $aVarB, $aVarC, $aVarD, $aVarE]
$count = UBound($arrar)
Select
Case $count == 1
$combinations = $arrar[0]
Case $count == 2
$combinations = _ArrayCombinationsX($arrar[0], $arrar[1])
Case $count >= 3
$combinations = _ArrayCombinationsX($arrar[0], $arrar[1])
For $i = 2 To $count - 1
$combinations = _ArrayCombinationsX($combinations, $arrar[$i])
Next
EndSelect
_ArrayDisplay($combinations)
Func _ArrayCombinationsX($avA1, $avA2)
If Not IsArray($avA1) Or Not IsArray($avA2) Then Return SetError(1)
Local $aRe[1] = [0], $element
For $i = 0 To UBound($avA1) - 1
For $j = 0 To UBound($avA2) - 1
$element = $avA1[$i] & $avA2[$j]
_ArrayAdd($aRe, $element)
Next
Next
_ArrayDelete($aRe, 0)
Return $aRe
EndFunc ;==>_ArrayCombinationsX
N组数组组合 |