Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
9
Task/Knuth-shuffle/C-sharp/knuth-shuffle.cs
Normal file
9
Task/Knuth-shuffle/C-sharp/knuth-shuffle.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
public static void KnuthShuffle<T>(T[] array)
|
||||
{
|
||||
System.Random random = new System.Random();
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
int j = random.Next(i, array.Length); // Don't select from the entire array on subsequent loops
|
||||
T temp = array[i]; array[i] = array[j]; array[j] = temp;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue