Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace messages
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- int numberOfLines = int.Parse(Console.ReadLine());
- string sumCurrentChar = " ";
- for (int i = 1; i <= numberOfLines; i++)
- {
- string input = Console.ReadLine();
- char[] inputCountArr = new char[input.Length]; // checker how many times the user is input same number
- char currentChar = '0';
- if (input.Contains("2"))
- {
- char[] content = new char[] { 'a', 'b', 'c' };
- currentChar = CalculateCurrentChar(inputCountArr, currentChar, content);
- }
- else if (input.Contains("3"))
- {
- char[] content = new char[] { 'D', 'e', 'f' };
- currentChar = CalculateCurrentChar(inputCountArr, currentChar, content);
- }
- else if (input.Contains("4"))
- {
- char[] content = new char[] { 'g', 'h', 'i' };
- currentChar = CalculateCurrentChar(inputCountArr, currentChar, content);
- }
- else if (input.Contains("5"))
- {
- char[] content = new char[] { 'j', 'k', 'l' };
- currentChar = CalculateCurrentChar(inputCountArr, currentChar, content);
- }
- else if (input.Contains("6"))
- {
- char[] content = new char[] { 'M', 'n', 'o' };
- currentChar = CalculateCurrentChar(inputCountArr, currentChar, content);
- }
- else if (input.Contains("7"))
- {
- char[] content = new char[] { 'p', 'q', 'r', 's' };
- currentChar = CalculateCurrentChar(inputCountArr, currentChar, content);
- }
- else if (input.Contains("8"))
- {
- char[] content = new char[] { 't', 'u', 'v' };
- currentChar = CalculateCurrentChar(inputCountArr, currentChar, content);
- }
- else if (input.Contains("9"))
- {
- char[] content = new char[] { 'W', 'x', 'y', 'z' };
- currentChar = CalculateCurrentChar(inputCountArr, currentChar, content);
- }
- else if (input.Contains("0"))
- {
- currentChar = ' ';
- }
- sumCurrentChar = sumCurrentChar+currentChar;
- }
- Console.WriteLine(sumCurrentChar.ToLower());
- }
- private static char CalculateCurrentChar(char[] inputCountArr, char currentChar, char[] content)
- {
- if (inputCountArr.Length == 1)
- {
- currentChar = content[0];
- }
- else if (inputCountArr.Length == 2)
- {
- currentChar = content[1];
- }
- else if (inputCountArr.Length == 3)
- {
- currentChar = content[2];
- }
- else if (inputCountArr.Length == 4 && content.Length==4)
- {
- currentChar = content[3];
- }
- else if (inputCountArr.Length >= content.Length)
- {
- currentChar = content[inputCountArr.Length % content.Length];
- }
- return currentChar;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement