本帖最后由 user3000 于 2014-12-9 21:05 编辑
回复 11# au3x
反正就是"遍历"再"遍历"......所以, 改一下2楼的代码就可以了.
现在是最多支持四个数组,你还可以继续照样子继续扩展.
#include <array.au3>
Dim $varA[4] = [5, 6, 7, 'a']
Dim $varB[3] = [1, 2, 3]
Dim $varC[3] = [9, 8, 7]
Dim $vard[6] = [9, 8, 7, 'b', 'c', 'd']
Local $aArray = _ArrayCombinationsX($varA, $varB, $varc, $vard)
_ArrayDisplay($aArray)
Func _ArrayCombinationsX($avA1, $avA2, $avA3 = Default, $avA4 = Default)
If Not IsArray($avA1) Or Not IsArray($avA2) Then Return SetError(1)
If IsArray($avA3) Then
Local $avA_3 = $avA3
Else
Local $avA_3[1]
EndIf
If IsArray($avA4) Then
Local $avA_4 = $avA4
Else
Local $avA_4[1]
EndIf
Local $aRe[1] = [0],$x=1
For $i = 0 To UBound($avA1)-1
For $j = 0 To UBound($avA2)-1
For $k = 0 To UBound($avA_3)-1
For $l = 0 To UBound($avA_4)-1
$aRe[0] = $x
ReDim $aRe[$x+1]
$aRe[$x] = $avA1[$i] & $avA2[$j] & $avA_3[$k] & $avA_4[$l]
$x+=1
Next
Next
Next
Next
Return $aRe
EndFunc
|