fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. // your code goes here
  9. Random rnd = new Random();
  10. List<int> test = new List<int>() {0,1,2,3,4,5,6,7,8,9,10,11};
  11. List<int> randomList = new List<int>();
  12.  
  13. Console.Write("All generated numbers: ");
  14. for ( ; randomList.Count < 7; ) {
  15. var random = rnd.Next(0, test.Count);
  16. if (!randomList.Contains(random)) {
  17. randomList.Add(random);
  18. }
  19. Console.Write(test[random] + ", ");
  20. }
  21.  
  22. Console.WriteLine("");
  23. Console.Write("unique indexes: ");
  24. foreach (var i in randomList) {
  25. Console.Write(i + ", ");
  26. }
  27.  
  28. randomList.Clear();
  29. }
  30. }
Success #stdin #stdout 0.06s 24032KB
stdin
Standard input is empty
stdout
All generated numbers: 11, 5, 8, 8, 0, 7, 7, 0, 3, 2, 
unique indexes: 11, 5, 8, 0, 7, 3, 2,