Advertisement
Stan0033

Untitled

Jun 25th, 2021
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.  
  6. namespace apps
  7. {
  8. class Program
  9. {
  10. static void Main()
  11. {
  12. //append arrays
  13.  
  14. string input = Console.ReadLine();
  15. input = RemoveWhitespace(input); //remove whitespaces
  16.  
  17.  
  18. List<string> arrays= input.Split('|').ToList(); // split into arrays
  19.  
  20. for (int i = 0; i < arrays.Count; i++) // pick every arrays and sort it
  21. {
  22. int[] numbersofIndex = new int[arrays[i].Length];
  23. for (int x = 0; x < arrays[i].Length; x++)
  24. {
  25. string thisString = arrays[i];
  26. numbersofIndex[x] = Convert.ToInt32(thisString[x].ToString());
  27. }
  28.  
  29.  
  30. arrays[i] = string.Empty;
  31. arrays[i] = string.Join(' ', numbersofIndex);
  32. }
  33.  
  34.  
  35.  
  36. for (int i = arrays.Count-1; i>=0; i--) // print in reverse order
  37. Console.Write(arrays[i] + " ");
  38.  
  39. }
  40.  
  41.  
  42. static string RemoveWhitespace(string input)
  43. {
  44. string newstring = string.Empty;
  45. foreach(char c in input)
  46. {
  47. if (c !=' ') { newstring += c.ToString(); }
  48. }
  49. return newstring;
  50. }
  51.  
  52. }
  53. }
  54.  
  55.  
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement