Russian (CIS)English (United Kingdom)

Счастье в жизни – то чего ты достиг. Смысл жизни – все те, кто тебя любят. Н.Н.Полозова

Простейшая программа макроса в Excel расчета микроматчей  личного первенства в баскетболе

Самая простая "подгонка" микроматчей  под имеющееся на тренировке число игроков:

Sub BСОСТАВ_МИКРОМАТЧЕЙ()
Dim F(15, 15), A(15) As Variant

n = Cells(1, 18): Nmik = Cells(2, 18)
'If n < 10 Then n = 15
'If Nmik < 10 Then Nmik = n + 1

For i = 1 To Nmik
A(1) = 0: A(2) = 0: A(3) = 0: A(4) = 0: A(5) = 0: A(6) = 0: A(7) = 0: A(8) = 0: A(9) = 0: A(10) = 0:

TTTT = 10000: SSS = 0
For i1 = 1 To n
For i2 = 1 To n
For i3 = 1 To n
For i4 = 1 To n
For i5 = 1 To n
If i1 i2 And i1 i3 And i1 i4 And i1 i5 And i2 i3 And i2 i4 And i2 i5 And i3 i4 And i3 i5 And i4 i5 Then
SSS = F(i1, i2) + F(i1, i3) + F(i1, i4) + F(i1, i5) + F(i2, i3) + F(i2, i4) + F(i2, i5) + F(i3, i4) + F(i3, i5) + F(i4, i5)
If SSS < TTTT Then
TTTT = SSS: A(1) = i1: A(2) = i2: A(3) = i3: A(4) = i4: A(5) = i5:
End If
End If
Next i5, i4, i3, i2, i1

Cells(i, 1) = A(1): Cells(i, 2) = A(2): Cells(i, 3) = A(3): Cells(i, 4) = A(4): Cells(i, 5) = A(5):
F(A(1), A(2)) = F(A(1), A(2)) + 1: F(A(1), A(3)) = F(A(1), A(3)) + 1: F(A(1), A(4)) = F(A(1), A(4)) + 1: F(A(1), A(5)) = F(A(1), A(5)) + 1:
F(A(2), A(1)) = F(A(2), A(1)) + 1: F(A(2), A(3)) = F(A(2), A(3)) + 1: F(A(2), A(4)) = F(A(2), A(4)) + 1: F(A(2), A(5)) = F(A(2), A(5)) + 1:
F(A(3), A(1)) = F(A(3), A(1)) + 1: F(A(3), A(2)) = F(A(3), A(2)) + 1: F(A(3), A(4)) = F(A(3), A(4)) + 1: F(A(3), A(5)) = F(A(3), A(5)) + 1:
F(A(4), A(1)) = F(A(4), A(1)) + 1: F(A(4), A(2)) = F(A(4), A(2)) + 1: F(A(4), A(3)) = F(A(4), A(3)) + 1: F(A(4), A(5)) = F(A(4), A(5)) + 1:
F(A(5), A(1)) = F(A(5), A(1)) + 1: F(A(5), A(2)) = F(A(5), A(2)) + 1: F(A(5), A(3)) = F(A(5), A(3)) + 1: F(A(5), A(4)) = F(A(5), A(4)) + 1:

TTTT = 1000: SSS = 0
For i1 = 1 To n
For i2 = 1 To n
For i3 = 1 To n
For i4 = 1 To n
For i5 = 1 To n
If i1 A(1) And i1 A(2) And i1 A(3) And i1 A(4) And i1 A(5) Then
If i2 A(1) And i2 A(2) And i2 A(3) And i2 A(4) And i2 A(5) Then
If i3 A(1) And i3 A(2) And i3 A(3) And i3 A(4) And i3 A(5) Then
If i4 A(1) And i4 A(2) And i4 A(3) And i4 A(4) And i4 A(5) Then
If i5 A(1) And i5 A(2) And i5 A(3) And i5 A(4) And i5 A(5) Then
If i1 i2 And i1 i3 And i1 i4 And i1 i5 Then
If i2 i3 And i2 i4 And i2 i5 And i3 i4 And i3 i5 And i4 i5 Then
SSS = F(i1, i2) + F(i1, i3) + F(i1, i4) + F(i1, i5) + F(i2, i3) + F(i2, i4) + F(i2, i5) + F(i3, i4) + F(i3, i5) + F(i4, i5)
If SSS < TTTT Then
TTTT = SSS: A(6) = i1: A(7) = i2: A(8) = i3: A(9) = i4: A(10) = i5:
End If
End If
End If
End If
End If
End If
End If
End If
Next i5, i4, i3, i2, i1

Cells(i, 6) = A(6): Cells(i, 7) = A(7): Cells(i, 8) = A(8): Cells(i, 9) = A(9): Cells(i, 10) = A(10):
F(A(6), A(7)) = F(A(6), A(7)) + 1: F(A(6), A(8)) = F(A(6), A(8)) + 1: F(A(6), A(9)) = F(A(6), A(9)) + 1: F(A(6), A(10)) = F(A(6), A(10)) + 1:
F(A(7), A(6)) = F(A(7), A(6)) + 1: F(A(7), A(8)) = F(A(7), A(8)) + 1: F(A(7), A(9)) = F(A(7), A(9)) + 1: F(A(7), A(10)) = F(A(7), A(10)) + 1:
F(A(8), A(6)) = F(A(8), A(6)) + 1: F(A(8), A(7)) = F(A(8), A(7)) + 1: F(A(8), A(9)) = F(A(8), A(9)) + 1: F(A(8), A(10)) = F(A(8), A(10)) + 1:
F(A(9), A(6)) = F(A(9), A(6)) + 1: F(A(9), A(7)) = F(A(9), A(7)) + 1: F(A(9), A(8)) = F(A(9), A(8)) + 1: F(A(9), A(10)) = F(A(9), A(10)) + 1:
F(A(10), A(6)) = F(A(10), A(6)) + 1: F(A(10), A(7)) = F(A(10), A(7)) + 1: F(A(10), A(8)) = F(A(10), A(8)) + 1: F(A(10), A(9)) = F(A(10), A(9)) + 1:
Next i
For i = 1 To 15
For j = 1 To 15
Cells(i + 21, 27 + j) = F(i, j)
Next j, i
End Sub



Полозов, А.А. Система  рейтинга  в игровых   видах   спорта и единоборствах:  Монография. Екатеринбург: Изд-во УГТУ-УПИ, 1995. 110 с.
Полозов, А.А. Рейтинг в спорте: вчера, сегодня, завтра / А.А.Полозов. – М.:Советский спорт, 2007 – 316с.
www.polozov.nemi-ekb.ru