Difference between revisions of "Solução: Problema da escrita no celular (Gustavo Ramos)"
From AdonaiMedrado.Pro.Br
Line 13: | Line 13: | ||
{'j','k','l','\0'}, | {'j','k','l','\0'}, | ||
− | {'m','n','o',' | + | {'m','n','o','\0'}, |
− | {'p','q','r',' | + | {'p','q','r','s'}, |
{'t','u','v','\0'}, | {'t','u','v','\0'}, |
Latest revision as of 23:29, 14 April 2009
public class TecladoCelular { private char[,] teclado = new char[,] {{'a','b','c','\0'}, {'d','e','f','\0'}, {'g','h','i','\0'}, {'j','k','l','\0'}, {'m','n','o','\0'}, {'p','q','r','s'}, {'t','u','v','\0'}, {'w','x','y','z'}}; public TecladoCelular() { } public string RetornarTeclas(string palavra){ string retorno = ""; for (int i = 0; i < palavra.Length; i++){ for (int j = 0; j <= teclado.GetUpperBound(0); j++){ for (int k = 0; k <= teclado.GetUpperBound(1); k++){ if (palavra[i] == teclado[j,k]){ retorno += "#"+(j + 2)+"="+(k +1) + "\n"; } } } } return retorno; } public string RetornarPalavra(){ string palavra = ""; int qtdeLetras = int.Parse(Console.ReadLine()); for (int i = 0; i < qtdeLetras; i++){ string str = Console.ReadLine(); int tecla = int.Parse(str.Substring(1,1)); int repeticoes = int.Parse(str.Substring(3,1)); palavra += teclado[tecla -2,repeticoes-1]; } return palavra; } }