Created
June 11, 2012 09:29
-
-
Save biac/2909297 to your computer and use it in GitHub Desktop.
Kujian - 参加者.cs (Create 時に並びをランダムにする)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IList<参加者> Create() | |
{ | |
// …前略 | |
}).ToList(); | |
int count = list.Count; | |
var rnd = new Random(); | |
for (int i = 0; i < count; i++) | |
{ | |
int src = rnd.Next(0, count); | |
int dest = (src + rnd.Next(1, count)) % count; | |
var tmp = list[dest]; | |
list[dest] = list[src]; | |
list[src] = tmp; | |
} | |
return list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment