fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7. public static void Main(string[] args)
  8. {
  9. random_test136();
  10. random_test157();
  11. }
  12. public static void Swap<T>(T[] array,int i,int j)
  13. {
  14. T tmp=array[i];
  15. array[i]=array[j];
  16. array[j]=tmp;
  17. }
  18. public static void random_test136()
  19. {
  20. Random random = new Random();
  21. var cnt = new int[10][];
  22. for(int c = 0 ; c < 10; c++)cnt[c]= new int[10];
  23.  
  24. for(int c = 0 ; c < 1000000; c++)
  25. {
  26. int[] array = {0,1,2,3,4,5,6,7,8,9};
  27. for(int i = 0; i < array.Length; ++i)
  28. {
  29. var rand = random.Next(array.Length);
  30. Swap(array, i, rand);
  31. }
  32. for(int i = 0; i < array.Length; ++i)
  33. {
  34. cnt[i][Array.IndexOf(array,i)]++;
  35. }
  36. }
  37. Console.WriteLine("random_test136");
  38. for(int c = 0 ; c < 10; c++)
  39. {
  40. Console.WriteLine(string.Join(",",cnt[c].Select(i=>i.ToString()).ToArray()));
  41. }
  42. Console.WriteLine();
  43. }
  44. public static void random_test157()
  45. {
  46. Random random = new Random();
  47. var cnt = new int[10][];
  48. for(int c = 0 ; c < 10; c++)cnt[c]= new int[10];
  49.  
  50. for(int c = 0 ; c < 1000000; c++)
  51. {
  52. int[] array = {0,1,2,3,4,5,6,7,8,9};
  53. for(int i = 0; i < array.Length; ++i)
  54. {
  55. var rand = random.Next(i,array.Length);
  56. Swap(array, i, rand);
  57. }
  58. for(int i = 0; i < array.Length; ++i)
  59. {
  60. cnt[i][Array.IndexOf(array,i)]++;
  61. }
  62. }
  63. Console.WriteLine("random_test157");
  64. for(int c = 0 ; c < 10; c++)
  65. {
  66. Console.WriteLine(string.Join(",",cnt[c].Select(i=>i.ToString()).ToArray()));
  67. }
  68. Console.WriteLine();
  69. }
  70. }
Success #stdin #stdout 3.64s 34312KB
stdin
Standard input is empty
stdout
random_test136
99951,100739,99584,99490,99911,99922,100410,100328,99744,99921
128519,94228,94508,95754,96019,96428,97617,97948,98740,100239
119189,124374,90175,90942,92479,93730,94927,96309,98286,99589
111822,116173,120873,87542,88630,90672,92847,94660,96933,99848
104591,108033,113470,119172,85893,88210,90105,93278,97083,100165
97704,101948,106709,111899,117789,85992,88871,92854,95996,100238
92437,96135,100968,105983,112500,118776,87325,90686,95537,99653
86602,90816,95923,100875,107029,113402,120357,90367,94641,99988
81529,85846,90907,95893,101968,108818,116357,123952,94701,100029
77656,81708,86883,92450,97782,104050,111184,119618,128339,100330

random_test157
99422,100955,99713,99325,99552,99814,100107,100542,100618,99952
99946,98967,99692,100363,100424,100364,100121,100228,100344,99551
100579,99787,99815,99699,100347,99925,99731,100156,100027,99934
99969,99865,99975,100088,99927,100189,99984,99976,99900,100127
100544,100363,100198,100367,100536,99338,99445,99643,99357,100209
99579,100131,99862,100363,100450,99730,100023,100182,99897,99783
99683,100600,99713,99914,99437,100134,100106,100085,100105,100223
99922,99781,100254,100489,99505,99831,100041,100028,100145,100004
100191,99648,100415,99569,99889,100618,100563,99472,99376,100259
100165,99903,100363,99823,99933,100057,99879,99688,100231,99958