Advertisement
Vranimir

Sort Three Numbers

Feb 12th, 2023
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 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. int one = int.Parse(Console.ReadLine());
  11. int two = int.Parse(Console.ReadLine());
  12. int three = int.Parse(Console.ReadLine());
  13.  
  14. bool oneBig = ((one >= two) && (one >= three));
  15. bool twoBig = ((two >= one) && (two >= three));
  16. bool threeBig = ((three >= two) && (three >= one));
  17. //1
  18. bool oneTwoThree = (two >= three);
  19. bool oneThreeTwo = (three >= two);
  20. //2
  21. bool twoOneThree = (one >= three);
  22. bool twoThreeOne = (three >= two);
  23. //3
  24. bool threeOneTwo = (one >= two);
  25. bool threeTwoOne = (three >= one);
  26.  
  27. bool condition = (((one >= -1000) && (two >= -1000) && (three >= -1000)) && ((one <= 1000) && (two <= 1000) && (three <= 1000)));
  28.  
  29. //1
  30. if (((one >= -1000) && (two >= -1000) && (three >= -1000)) && ((one <= 1000) && (two <= 1000) && (three <= 1000)))
  31. {
  32. if ((oneBig) && (oneTwoThree) && (condition))
  33. {
  34. Console.WriteLine($"{one} {two} {three}");
  35. }
  36. else if ((oneBig) && (oneThreeTwo)&& (condition))
  37. {
  38. Console.WriteLine($"{one} {three} {two}");
  39. }
  40. //2
  41. else if ((twoBig) && (twoOneThree) && (condition))
  42. {
  43. Console.WriteLine($"{two} {one} {three}");
  44. }
  45. else if ((twoBig) && (twoThreeOne) && (condition))
  46. {
  47. Console.WriteLine($"{two} {three} {one}");
  48. }
  49. //3
  50. else if ((threeBig) && (threeOneTwo) && (condition))
  51. {
  52. Console.WriteLine($"{three} {one} {two}");
  53. }
  54. else if ((threeBig) && (threeTwoOne) && (condition))
  55. {
  56. Console.WriteLine($"{threeTwoOne}");
  57. }
  58. }
  59. }
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement