Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Sort 3 real values in descending order using nested if statements.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Globalization;
- namespace _04.SortDescending
- {
- class SortDescending
- {
- static void Main(string[] args)
- {
- Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
- Console.WriteLine("Please enter three numbers:");
- decimal a = decimal.Parse(Console.ReadLine());
- decimal b = decimal.Parse(Console.ReadLine());
- decimal c = decimal.Parse(Console.ReadLine());
- if (a>=b)
- {
- if (a>=c)
- {
- if (b>=c)
- {
- Console.WriteLine("The numbers in Descending order are: {0} , {1} , {2}.",a,b,c);
- }
- else
- {
- Console.WriteLine("The numbers in Descending order are: {0} , {1} , {2}.", a, c, b);
- }
- }
- else
- {
- Console.WriteLine("The numbers in Descending order are: {0} , {1} , {2}.", c, a, b);
- }
- }
- else
- {
- if (b>=c)
- {
- if (c>=a)
- {
- Console.WriteLine("The numbers in Descending order are: {0} , {1} , {2}.", b, c, a);
- }
- else
- {
- Console.WriteLine("The numbers in Descending order are: {0} , {1} , {2}.", b, a, c);
- }
- }
- else
- {
- Console.WriteLine("The numbers in Descending order are: {0} , {1} , {2}.", c, b, a);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement