fork(8) download
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. using System.Collections.Generic;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. // your code goes here
  11. IEnumerable<int> resultNums = Enumerable.Range(1, 45).Shuffle().Take(5).OrderBy(n => n);
  12.  
  13. StringBuilder sb = new StringBuilder();
  14. foreach (int num in resultNums)
  15. {
  16. sb.Append(num + " ");
  17. }
  18.  
  19. Console.WriteLine(sb);
  20.  
  21. }
  22. }
  23.  
  24. public static class EnumerableExtension
  25. {
  26. public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> collection)
  27. {
  28. System.Random random = new System.Random();
  29. return collection.OrderBy(node => random.Next());
  30. }
  31. }
Success #stdin #stdout 0.05s 24080KB
stdin
Standard input is empty
stdout
16 23 34 39 45