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("Введите двухзначное число: ");
- string userInput = Console.ReadLine();
- int result;
- if (userInput.Length < 2 || userInput.Length > 2)
- {
- Console.WriteLine("Ошибка ввода");
- }
- else
- {
- ChangeDigits(ref userInput);
- if (int.TryParse(userInput, out result))
- Console.WriteLine($"Результат: {result}");
- else
- Console.WriteLine("Вводите числа!");
- }
- }
- private static void ChangeDigits(ref string value)
- {
- value = $"{value[1]}{value[0]}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment