BSO90

Sort Three Numbers

May 5th, 2021
796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Sort_Three_Numbers
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double firstNum = double.Parse(Console.ReadLine());
  10.             double secondNum = double.Parse(Console.ReadLine());
  11.             double thirdNum = double.Parse(Console.ReadLine());
  12.             double maxValue = 0;
  13.             double minValue = 0;
  14.             double middleValue = 0;
  15.             maxValue = Math.Max(Math.Max(firstNum, secondNum), thirdNum);
  16.             minValue = Math.Min(Math.Min(firstNum, secondNum), thirdNum);
  17.             if (maxValue == firstNum || maxValue == secondNum)
  18.             {
  19.                 if (minValue == firstNum || minValue == secondNum)
  20.                 {
  21.                     middleValue = thirdNum;
  22.                 }
  23.             }
  24.  
  25.             if (maxValue == firstNum || maxValue == thirdNum)
  26.             {
  27.                 if (minValue == firstNum || minValue == thirdNum)
  28.                 {
  29.                     middleValue = secondNum;
  30.                 }
  31.             }
  32.  
  33.             if (maxValue == secondNum || maxValue == thirdNum)
  34.             {
  35.                 if (minValue == secondNum || minValue == thirdNum)
  36.                 {
  37.                     middleValue = firstNum;
  38.                 }
  39.             }
  40.             Console.WriteLine($"{maxValue} {middleValue} {minValue}");
  41.         }
  42.     }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment