Created
April 3, 2015 19:17
-
-
Save rogerioagjr/92634e69ccbd02c79056 to your computer and use it in GitHub Desktop.
Problema da Semana - Semana 2 - Informática - Iniciante
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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