vb 多个数组排列组合
输入t1=(1,2,3)t2=(5,7,8)t3=(9,11,12)输出三个数组内数的组合1591511151217917111712189181118122592511...
输入
t1 = (1,2,3)
t2 = (5,7, 8)
t3 = (9,11,12)
输出三个数组内数的组合
1 5 9
1 5 11
1 5 12
1 7 9
1 7 11
1 7 12
1 8 9
1 8 11
1 8 12
2 5 9
2 5 11
2 5 12
2 7 9
2 7 11
2 7 12
2 8 9
2 8 11
2 8 12
3 5 9
3 5 11
3 5 12
3 7 9
3 7 11
3 7 12
3 8 9
3 8 11
3 8 12 展开
t1 = (1,2,3)
t2 = (5,7, 8)
t3 = (9,11,12)
输出三个数组内数的组合
1 5 9
1 5 11
1 5 12
1 7 9
1 7 11
1 7 12
1 8 9
1 8 11
1 8 12
2 5 9
2 5 11
2 5 12
2 7 9
2 7 11
2 7 12
2 8 9
2 8 11
2 8 12
3 5 9
3 5 11
3 5 12
3 7 9
3 7 11
3 7 12
3 8 9
3 8 11
3 8 12 展开
1个回答
展开全部
Private Sub Command1_Click()
List1.Clear
Dim t1(), t2(), t3(), t()
t1 = Array(1, 2, 3, 4)
t2 = Array(5, 7, 8, 10)
t3 = Array(9, 11, 12, 18, 22, 24, 25)
t = Array(t1, t2, t3)
For i = LBound(t) To UBound(t)
Label1(i) = "t" + CStr(i + 1) + " =("
For j = LBound(t(i)) To UBound(t(i))
If j < UBound(t(i)) Then
Label1(i) = Label1(i) + CStr(t(i)(j)) + ","
Else
Label1(i) = Label1(i) + CStr(t(i)(j)) + ")"
End If
Next j
Next i
For i = LBound(t(0)) To UBound(t(0))
For j = LBound(t(1)) To UBound(t(1))
For k = LBound(t(2)) To UBound(t(2))
List1.AddItem CStr(t(0)(i)) + Space(1) + CStr(t(1)(j)) + Space(1) + CStr(t(2)(k))
Next k
Next j
Next i
Label2.Caption = "共计" + CStr((UBound(t(0)) + 1) * (UBound(t(1)) + 1) * (UBound(t(2)) + 1)) + "种"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询