缘由https://bbs.csdn.net/topics/397512167 首先写了自上而下的查找,在此基础上再加逻辑控制以达到目标。
vbnet
Sub 四维组合()
Dim wei4 = {{4, 5, 6, 7}, {1, 2, 4, 8}, {9, 10, 11, 12}, {3, 13, 21, 22}}
Dim j = 1, h = 0, f = 0, zc = wei4(0, f)
Dim sc = ""
While f < 4
If j < 4 Then
If zc < wei4(j, h) Then
sc += zc.ToString + " "
zc = wei4(j, h)
If j = 3 Then
sc += zc.ToString + Chr(13) + Chr(10)
End If
j += 1
h = 0
Else
h += 1
End If
If h >= 4 Then
j += 1
h = 0
End If
Else
j = 1
f += 1
zc = wei4(0, f)
End If
End While
End Sub