Anonim_999

2.5

Dec 22nd, 2022
786
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp27
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Введите двухзначное число: ");
  10.             string userInput = Console.ReadLine();
  11.             int result;
  12.  
  13.             if (userInput.Length < 2 || userInput.Length > 2)
  14.             {
  15.                 Console.WriteLine("Ошибка ввода");
  16.             }
  17.             else
  18.             {
  19.                 ChangeDigits(ref userInput);
  20.  
  21.                 if (int.TryParse(userInput, out result))
  22.                     Console.WriteLine($"Результат: {result}");
  23.                 else
  24.                     Console.WriteLine("Вводите числа!");
  25.             }
  26.         }
  27.  
  28.         private static void ChangeDigits(ref string value)
  29.         {
  30.             value = $"{value[1]}{value[0]}";
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment