desislava_topuzakova

Untitled

Oct 17th, 2023
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. int clicks = int.Parse(Console.ReadLine());
  2. string message = string.Empty;
  3.  
  4. for (int i = 0; i < clicks; i++)
  5. {
  6. string digits = Console.ReadLine();
  7. int digitLength = digits.Length;
  8. int digit = digits[0] - '0'; // ASCII hack hehehe
  9. int offset = (digit - 2) * 3;
  10.  
  11. if (digit == 0)
  12. {
  13. message += (char)(digit + 32);
  14. continue;
  15. }
  16.  
  17. if (digit == 8 || digit == 9)
  18. {
  19. offset++;
  20. }
  21. int letterIndex = offset + digitLength - 1;
  22. message += (char)(letterIndex + 97);
  23. }
  24.  
  25. Console.WriteLine(message);
Advertisement
Add Comment
Please, Sign In to add comment