Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace SortNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- int firstNum = int.Parse(Console.ReadLine());
- int secondNum = int.Parse(Console.ReadLine());
- int thirdNum = int.Parse(Console.ReadLine());
- for (int i = 0; i < 3; i++)
- {
- if (firstNum > secondNum && firstNum > thirdNum)
- {
- Console.WriteLine(firstNum);
- firstNum = int.MinValue;
- }
- else if (secondNum > firstNum && secondNum > thirdNum)
- {
- Console.WriteLine(secondNum);
- secondNum = int.MinValue;
- }
- else
- {
- Console.WriteLine(thirdNum);
- thirdNum = int.MinValue;
- }
- }
- }
- }
- }
- Решение с масив и фор цикли:
- using System;
- namespace SortNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] arr = new int[3];
- for (int i = 0; i < 3; i++)
- {
- arr[i] = int.Parse(Console.ReadLine());
- }
- Array.Sort(arr);
- for (int i = 2; i >= 0; i--)
- {
- Console.WriteLine(arr[i]);
- }
- }
- }
- }
- Решение с масив и малко LINQ - Яко, нали!:)
- using System;
- using System.Linq;
- namespace SortNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] numbers = { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() };
- Array.Sort(numbers);
- Console.WriteLine(string.Join("\n", numbers.Reverse()));
- }
- }
- }
Add Comment
Please, Sign In to add comment