f0rc3ful

Sort Numbers C#

Jan 30th, 2023 (edited)
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. class Program
  7. {
  8. static void Main()
  9. {
  10. string inputraw = Console.ReadLine();
  11. string[] input = inputraw.Split(", ");
  12. int[] inputint = new int[inputClean.Length];
  13. for (int i = 0; i < input.Length; i++)
  14. {
  15. inputint[i] = int.Parse(input[i]);
  16. }
  17. Array.Sort(inputint);
  18. Array.Reverse(inputint);
  19. // foreach (int inaput in inputint) { Console.Write($"{inaput}, "); }
  20. for (int i = 0; i < inputClean.Length; i++)
  21. {
  22. if (i == inputint.Length - 1)
  23. {
  24. Console.Write($"{inputint[i]}");
  25. }
  26. else { Console.Write($"{inputint[i]}, "); }
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment