Advertisement
skipter

Sms Typing - Array C#

Jun 10th, 2017
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int countCharacters = int.Parse(Console.ReadLine());
  13.             int[] array = new int[26];
  14.             string result = string.Empty;
  15.             for (int i = 0; i < countCharacters; i++)
  16.             {
  17.                 int textMessage = int.Parse(Console.ReadLine());
  18.                 if (textMessage == 0)
  19.                 {
  20.                     result += " ";
  21.                 }
  22.                 else
  23.                 {
  24.                     int len = textMessage.ToString().Length;
  25.                     int mainDigit = textMessage % 10;
  26.                     int startIndex = (mainDigit - 2) * 3;
  27.  
  28.                     if (mainDigit == 8 || mainDigit == 9)
  29.                     {
  30.                         startIndex++;
  31.                     }
  32.                     int letterIndex = startIndex + len - 1;
  33.                     result+= (char)(97 + letterIndex);
  34.                 }
  35.             }
  36.             Console.WriteLine(result);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement