参考代码
Dim rs As Integer = 5
Dim cs As Integer = 2
Dim dic_r As new Dictionary(of String, Integer)
Dim dic_b As new Dictionary(of String, Boolean)
For i As Integer = 1 To rs
dic_r.add(i, 0)
For j As Integer = i+1 To rs
dic_b.add(i & "," & j, False)
Next
Next
Do While True
Dim min As Integer = 999
Dim dic_bx As new Dictionary(of String, Integer)
Dim ls_bx As new List(Of String)
Dim arykey() As String = Nothing
For Each key As String In dic_b.keys
If dic_b(key) = False Then
Dim ary As String() = key.split(",")
Dim s As Integer = dic_r(ary(0)) + dic_r(ary(1))
If s <= min Then
min = s
arykey = ary
End If
End If
Next
If arykey Is Nothing Then
Exit Do
Else
dic_r(arykey(0)) += 1 '场次+1
dic_r(arykey(1)) += 1
dic_b(arykey(0) & "," & arykey(1)) = True '把此场设置为比赛
output.show(arykey(0) & "," & arykey(1) & "(" & dic_r(arykey(0)) & " : " & dic_r(arykey(1)) & ")")
End If
Loop