Advertisement
Radost09

Messages

Jan 24th, 2022
975
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P05_Messages
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int tapTimes = int.Parse(Console.ReadLine());
  10.             string message = "";
  11.  
  12.             for (int i = 1; i <= tapTimes; i++)
  13.             {
  14.                 int input = int.Parse(Console.ReadLine());
  15.                 int lenght = input.ToString().Length;
  16.                 int mainDigit = input % 10;
  17.                 int offset = (mainDigit - 2) * 3;
  18.  
  19.                 if(mainDigit==8 || mainDigit==9)
  20.                 {
  21.                     offset += 1;
  22.                 }
  23.                 int indexLetter = offset + lenght - 1;
  24.  
  25.                 if(mainDigit != 0)
  26.                 {
  27.                     message += (char)(indexLetter + 97);
  28.                 }
  29.                 else
  30.                 {
  31.                     message += (char)(32);
  32.                 }
  33.             }
  34.             Console.WriteLine(message);
  35.         }
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement