fork(4) download
  1. using System;
  2.  
  3. public class Sorteio
  4. {
  5. static Random _random = new Random();
  6.  
  7. public static void Shuffle<T>(T[] array)
  8. {
  9. var random = _random;
  10. for (int i = array.Length; i > 1; i--)
  11. {
  12. int j = random.Next(i);
  13. T tmp = array[j];
  14. array[j] = array[i - 1];
  15. array[i - 1] = tmp;
  16. }
  17. }
  18.  
  19. public static void Main()
  20. {
  21. string[] array = { "Alaor", "Joseval", "Salustiano", "Gomide", "Castro" };
  22. Shuffle(array);
  23. foreach (string value in array)
  24. {
  25. Console.WriteLine(value);
  26. }
  27. }
  28. }
Success #stdin #stdout 0.02s 33928KB
stdin
Standard input is empty
stdout
Salustiano
Castro
Alaor
Gomide
Joseval