基本上我的球员名单,我想配对起来,使每个玩家将扮演人人一次。什么是找到这个数据的最快方法是什么?
Basically I have list of players, and I want to pair them up so that each player will play everyone once. What's the quickest way to find this data?
假设选手不出现在列表两次,双为
循环是非常快:
assuming that players do not appear in the list twice, a double for
loop is very quick:
for (int i=0, i <= playerList.Count - 2, i++)
for (int j=i+1, j <= playerList.Count - 1, j++)
//add a new pairing of player i and j