Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp27
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Введите 2 числа: ");
- string aInput = Console.ReadLine();
- string bInput = Console.ReadLine();
- string cInput;
- int a, b, c;
- if (int.TryParse(aInput, out a) && int.TryParse(bInput,out b))
- {
- MinMax(ref a, ref b);
- Console.WriteLine($"{a} {b}");
- }
- else
- {
- Console.WriteLine("Ошибка ввода!");
- }
- Console.WriteLine("Введите 3 числа: ");
- aInput = Console.ReadLine();
- bInput = Console.ReadLine();
- cInput = Console.ReadLine();
- if (int.TryParse(aInput, out a)
- && int.TryParse(bInput, out b)
- && int.TryParse(cInput, out c))
- {
- MinMax(ref a, ref b, ref c);
- Console.WriteLine($"{a} {b} {c}");
- }
- }
- private static void MinMax(ref int a, ref int b)
- {
- int temp = 0;
- if (a < b)
- {
- temp = a;
- a = b;
- b = temp;
- }
- }
- private static void MinMax(ref int a, ref int b, ref int c)
- {
- int temp = 0;
- if (a < b)
- {
- temp = a;
- a = b;
- b = temp;
- }
- if (a < c)
- {
- temp = a;
- a = c;
- c = temp;
- }
- if (b < c)
- {
- temp = c;
- c = b;
- b = temp;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment