coasterka

#5SortThreeNumrsWithNestedIfs

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