0
這對我有用,但我不明白它是如何工作的。誰能解釋一下?聯賽夾具算法說明
for(int round = 0; round < rounds_count; round++)
{
for(int match = 0; match < matches_per_round; match++)
{
int home = (round + match) % (teams_count - 1);
int away = (teams_count - 1 - match + round) % (teams_count - 1);
if(match == 0)
away = teams_count - 1;
matches.push_back(Match(&teams[home], &teams[away], round));
}
}
模數的竅門是什麼?
你確定這應該是'%(teams_count-1)'而不是'%teams_count'? –
我真的不知道。我只是在網絡的某個地方發現了這個代碼。它適合我。 – micnyk
看起來似乎寫道,最後一支球隊永遠不會成爲比賽的一部分,除非特殊情況下最後一支球隊是第一場比賽的客隊。也許這對於這個聯盟來說是正確的行爲,但這似乎有點奇怪。 –