Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SortThreeNumbersWithNestedIfs
- {
- class SortThreeNumbersWithNestedIfs
- {
- static void Main()
- {
- double a, b, c;
- Console.WriteLine("Enter first number: ");
- a = double.Parse(Console.ReadLine());
- Console.WriteLine("Enter second number: ");
- b = double.Parse(Console.ReadLine());
- Console.WriteLine("Enter third number: ");
- c = double.Parse(Console.ReadLine());
- Console.WriteLine();
- double max = a;
- double middle;
- double min;
- if (a > b && a > c)
- {
- max = a;
- if (b > c)
- {
- middle = b;
- min = c;
- }
- else
- {
- middle = c;
- min = b;
- }
- Console.WriteLine("{0,1} {1,1} {2,1}",max,middle,min);
- }
- ///////////////////////
- if (b > a && b > c)
- {
- max = b;
- if (a > c)
- {
- middle = a;
- min = c;
- }
- else
- {
- middle = c;
- min = a;
- }
- Console.WriteLine("{0,1} {1,1} {2,1}", max, middle, min);
- }
- /////////////////////////
- if (c > a && c > b)
- {
- max = c;
- if (a > b)
- {
- middle = a;
- min = b;
- }
- else
- {
- middle = b;
- min = a;
- }
- Console.WriteLine("{0,1} {1,1} {2,1}", max, middle, min);
- }
- ////////////////////////
- if (a == b && b == c)
- {
- Console.WriteLine("{0,1} {1,1} {2,1}", a, b, c);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment