Advertisement
simeon_stoykov

Sort 3 Numbers with Nested Ifs

Jul 31st, 2014
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Sort3NumbersWithNestedIfs
  8. {
  9.     class Sort3NumbersWithNestedIfs
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double a = double.Parse(Console.ReadLine());
  14.             double b = double.Parse(Console.ReadLine());
  15.             double c = double.Parse(Console.ReadLine());
  16.  
  17.             if (a>=b && a>c)
  18.             {
  19.                 if (b>=c)
  20.                 {
  21.                     Console.WriteLine("{0} {1} {2}", a, b, c);
  22.                 }
  23.                 else
  24.                 {
  25.                     Console.WriteLine("{0} {1} {2}", a, c, b);
  26.                 }
  27.             }
  28.  
  29.             if (b>a && b>=c)
  30.             {
  31.                 if (a>=c)
  32.                 {
  33.                     Console.WriteLine("{0} {1} {2}", b, a, c);
  34.                 }
  35.                 else
  36.                 {
  37.                     Console.WriteLine("{0} {1} {2}", b, c, a);
  38.                 }
  39.             }
  40.             if (c >= a && c > b)
  41.             {
  42.                 if (a >= b)
  43.                 {
  44.                     Console.WriteLine("{0} {1} {2}", c, a, b);
  45.                 }
  46.                 else
  47.                 {
  48.                     Console.WriteLine("{0} {1} {2}", c, b, a);
  49.                 }
  50.             }
  51.             if (a==b && a==c)
  52.             {
  53.                 Console.WriteLine("{0} {1} {2}", c, b, a);
  54.             }
  55.  
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement