Advertisement
GogoK

SortByNested_Ifs

Feb 16th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2.  
  3. class SortByNestedIfs
  4. {
  5.     static void Main()
  6.     {
  7.         Console.WriteLine("Enter three numbers");
  8.         Console.Write("a=   ");
  9.         double a = double.Parse(Console.ReadLine());
  10.         Console.Write("b=   ");
  11.         double b = double.Parse(Console.ReadLine());
  12.         Console.Write("c=   ");
  13.         double c = double.Parse(Console.ReadLine());
  14.  
  15.         if (a > b && a > c)
  16.         {
  17.             if (b > c)
  18.             {
  19.                 Console.WriteLine("{0} {1} {2}", a, b, c);
  20.                 return;
  21.             }
  22.             else
  23.             {
  24.                 Console.WriteLine("{0} {1} {2}", a, c, b);
  25.                 return;
  26.             }
  27.         }
  28.         else if (b > c)
  29.         {
  30.             if (a > c)
  31.             {
  32.                 Console.WriteLine("{0} {1} {2}", b, a, c);
  33.             }
  34.             else
  35.             {
  36.                 Console.WriteLine("{0} {1} {2}", b, c, a);
  37.             }
  38.         }
  39.         else
  40.         {
  41.             if (a > b)
  42.             {
  43.                 Console.WriteLine("{0} {1} {2}", c, a, b);
  44.             }
  45.             else
  46.             {
  47.                 Console.WriteLine("{0} {1} {2}", c, b, a);
  48.             }
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement