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()
  8. {
  9. List<List<string>> input = new List<List<string>>();
  10. string @in;
  11.  
  12. do{
  13. @in = Console.ReadLine();
  14. if (!string.IsNullOrWhiteSpace(@in)){
  15. input.Add(@in.Split(' ').ToList());
  16. }
  17. }while(!string.IsNullOrWhiteSpace(@in));
  18.  
  19. var comparer = new NumberStringComparer();
  20.  
  21. for(int i = 0; i < input.Count; i++){
  22. var nums = input[i];
  23. nums.Sort(comparer);
  24.  
  25. Console.Write($"{string.Join("", nums)} ");
  26. nums.Reverse();
  27. Console.WriteLine(string.Join("", nums));
  28. }
  29. }
  30. }
  31.  
  32. class NumberStringComparer : IComparer<string>{
  33. public int Compare(string x, string y){
  34. return (x + y).CompareTo(y + x);
  35. }
  36. }
  37.  
Success #stdin #stdout 0.01s 132352KB
stdin
5 56 50
79 82 34 83 69
420 34 19 71 341
17 32 91 7 46
stdout
50556 56550
3469798283 8382796934
193413442071 714203434119
173246791 917463217