|
本帖最后由 yangyangzhifeng 于 2013-2-9 10:53 编辑
在论坛大概搜索了一下,好像还没有完整的讨论,算是抛砖引玉吧
单循环比赛对阵.rar
(14.42 KB, 下载次数: 580)
包含两种方法
- Sub gdlh() '固定轮换法
- Dim ar, i&, j&, x&, n&, lunci&, y&, t&
- Dim br, k
- Const duishu = 15
- If duishu Mod 2 = 0 Then
- n = duishu / 2: lunci = duishu - 1: t = duishu
- Else
- n = (duishu + 1) / 2: lunci = duishu: t = 0
- End If
- ReDim ar(1 To n, 1 To 2): ReDim br(1 To lunci, 1 To n)
- ar(1, 1) = 1
- For i = 1 To lunci
- x = x + 1: x = IIf(x > 2 * n, 2, x)
- y = x
- For j = 2 To 2 * n
- y = y + 1
- If y > 2 * n Then y = 2
- ar(r(y, n), c(y, n)) = IIf(j = 2 * n, t, j)
- Next
- For k = 1 To UBound(ar)
- br(i, k) = Format(ar(k, 1), "000") & "_" & Format(ar(k, 2), "000")
- Next
- Next
- Sheet1.Cells.ClearContents
- Sheet1.[a1].Resize(lunci, n).Columns.AutoFit
- Sheet1.[a1].Resize(lunci, n) = br
- End Sub
- Function r(ByVal x As Long, n&)
- x = IIf(x <= n, x, 3 * n - x + 1)
- r = 1 + ((x - 1) Mod n)
- End Function
- Function c(ByVal x As Long, n&)
- x = IIf(x <= n, x, 3 * n - x + 1)
- c = (x - 1) \ n + 1
- End Function
复制代码
|
评分
-
2
查看全部评分
-
|