Skip to content

Instantly share code, notes, and snippets.

@rogerioagjr
Created April 3, 2015 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogerioagjr/92634e69ccbd02c79056 to your computer and use it in GitHub Desktop.
Save rogerioagjr/92634e69ccbd02c79056 to your computer and use it in GitHub Desktop.
Problema da Semana - Semana 2 - Informática - Iniciante
#include <cstdio>
char letra;
int main(){
while(true){ // inicie um loop infinito
scanf("%c", &letra); // leia a letra da vez
if(letra=='\n') break; // se for uma quebra de linha, a entrada acabou
// caso contrário, cheque a que tecla a letra pertence
if(letra=='A' || letra=='B' || letra=='C') printf("2");
if(letra=='D' || letra=='E' || letra=='F') printf("3");
if(letra=='G' || letra=='H' || letra=='I') printf("4");
if(letra=='J' || letra=='K' || letra=='L') printf("5");
if(letra=='M' || letra=='N' || letra=='O') printf("6");
if(letra=='P' || letra=='Q' || letra=='R' || letra=='S') printf("7");
if(letra=='T' || letra=='U' || letra=='V') printf("8");
if(letra=='W' || letra=='X' || letra=='Y' || letra=='Z') printf("9");
if(letra=='-') printf("-"); // se for um hífen, imprima hífen
}
printf("\n"); // imprima um \n após o fim da entrada para evitar presentation error
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment