using System; using System.Collections.Generic; using System.Linq; public class Test { public static void Main(string[] args) { random_test136(); random_test157(); } public static void Swap(T[] array,int i,int j) { T tmp=array[i]; array[i]=array[j]; array[j]=tmp; } public static void random_test136() { Random random = new Random(); var cnt = new int[10][]; for(int c = 0 ; c < 10; c++)cnt[c]= new int[10]; for(int c = 0 ; c < 1000000; c++) { int[] array = {0,1,2,3,4,5,6,7,8,9}; for(int i = 0; i < array.Length; ++i) { var rand = random.Next(array.Length); Swap(array, i, rand); } for(int i = 0; i < array.Length; ++i) { cnt[i][Array.IndexOf(array,i)]++; } } Console.WriteLine("random_test136"); for(int c = 0 ; c < 10; c++) { Console.WriteLine(string.Join(",",cnt[c].Select(i=>i.ToString()).ToArray())); } Console.WriteLine(); } public static void random_test157() { Random random = new Random(); var cnt = new int[10][]; for(int c = 0 ; c < 10; c++)cnt[c]= new int[10]; for(int c = 0 ; c < 1000000; c++) { int[] array = {0,1,2,3,4,5,6,7,8,9}; for(int i = 0; i < array.Length; ++i) { var rand = random.Next(i,array.Length); Swap(array, i, rand); } for(int i = 0; i < array.Length; ++i) { cnt[i][Array.IndexOf(array,i)]++; } } Console.WriteLine("random_test157"); for(int c = 0 ; c < 10; c++) { Console.WriteLine(string.Join(",",cnt[c].Select(i=>i.ToString()).ToArray())); } Console.WriteLine(); } }