Venciity

[Jumpstart C#] Conditional statements - Ascending

Jan 24th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.91 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 _5.Ascending
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.Write("a = ");
  14.             int a = Int32.Parse(Console.ReadLine());
  15.             Console.Write("b = ");
  16.             int b = Int32.Parse(Console.ReadLine());
  17.             Console.Write("c = ");
  18.             int c = Int32.Parse(Console.ReadLine());
  19.  
  20.             if (a > b) // b a
  21.             {
  22.                 if (c < b) // c b a
  23.                     Console.WriteLine("{0} {1} {2}", c, b, a);
  24.                 else if (c > a) // b a c
  25.                     Console.WriteLine("{0} {1} {2}", b, a, c);
  26.                 else // b c a     ( c>= b && c <= a )
  27.                     Console.WriteLine("{0} {1} {2}", b, c, a);
  28.             }
  29.             else // a b   (a <= b )
  30.             {
  31.                 if (c < a) // c a b
  32.                     Console.WriteLine("{0} {1} {2}", c, a, b);
  33.                 else if (c > b) // a b c
  34.                     Console.WriteLine("{0} {1} {2}", a, b, c);
  35.                 else // a c b
  36.                     Console.WriteLine("{0} {1} {2}", a, c, b);
  37.             }
  38.  
  39.  
  40.  
  41.             //if (a <= b && b <= c) //a b c
  42.             //    Console.WriteLine("{0} {1} {2}", a, b, c);
  43.             //else if (a <= c && c <= b) // a c b
  44.             //    Console.WriteLine("{0} {1} {2}", a, c, b);
  45.             //else if (b <= a && a <= c) // b a c
  46.             //    Console.WriteLine("{0} {1} {2}", b, a, c);
  47.             //else if (b <= c && c <= a) // b c a
  48.             //    Console.WriteLine("{0} {1} {2}", b, c, a);
  49.             //else if (c <= a && a <= b) // c a b
  50.             //    Console.WriteLine("{0} {1} {2}", c, a, b);
  51.             //else if (c <= b && b <= a)  // c b a
  52.             //    Console.WriteLine("{0} {1} {2}", c, b, a);
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment