从Forming a tournament table with LINQ (Fixture List)
添加数字列表时,例如。
var fixture = ListMatches(new List<string> { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16" });
当我运行代码时,1号总是第二个。例如
Round 1
9 v 1
Round 2
10 v 1
Round 3
11 v 1
我正努力想办法修改密码,使每一轮的数字都能从“家”和“外”交替出现所以如果1号是第二轮,下一轮是第一轮,如果16号是第一轮,那么它就是第二轮,客场,在第二轮。
Round 1
9 v 1
Round 2
1 v 10
Round 3
11 v 1
最佳答案
这可能是一个愚蠢的建议,但你可以改变游戏的顺序玩偶数轮。
List<List<Tuple<string, string>>> fixture =
ListMatches(new List<string> { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16" });
bool switchOrder = false;
foreach (round in fixture)
{
if (switchOrder)
{
foreach (var tuple in round)
{
string temp = tuple.Item1;
tuple.Item1 = tuple.Item2;
tuple.Item2 = temp;
}
}
switchOrder = !switchOrder
}
关于c# - 治具制作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14025065/