Advertisement
bullit3189

Messages - BasicSyntax

Jan 27th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5.  
  6. public class Program
  7. {
  8. public static void Main()
  9. {
  10. string result = string.Empty;
  11.  
  12. int n = int.Parse(Console.ReadLine());
  13.  
  14. for (int i=0; i<n; i++)
  15. {
  16. int currNum = int.Parse(Console.ReadLine());
  17. string numAsString = currNum.ToString();
  18. int currNumLen = numAsString.Length;
  19.  
  20. int mainDigit = currNum%10;
  21.  
  22. int offset = (mainDigit-2)*3;
  23.  
  24. if (mainDigit == 8 || mainDigit==9)
  25. {
  26. offset+=1;
  27. }
  28.  
  29. int letterIndex = (offset + currNumLen -1);
  30.  
  31. char symbol = (char)(letterIndex + 97);
  32.  
  33. if (symbol<97)
  34. {
  35. symbol = ' ';
  36. }
  37. result += symbol;
  38. }
  39.  
  40. Console.WriteLine(result);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement