Last active
June 17, 2018 16:45
-
-
Save requeijaum/0a043bc78052709299291d350bd16d9a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <stdio.h> | |
int main(){ | |
char telefone[100]; | |
char out[100]; | |
int soma=0, a=0, tamanho=0; | |
char valido[11] = "-0123456789"; | |
scanf("%s", telefone); | |
while(telefone[a]!='\0'){ | |
soma=soma+1; | |
a++; | |
} | |
for(int i=0; i < soma ; i++){ | |
if(telefone[i] == '-'){ | |
out[i] = '-'; tamanho=tamanho+1; tamanho=tamanho+1; | |
} | |
else if(telefone[i] == '0' ){ | |
out[i] = '0'; tamanho=tamanho+1; | |
} | |
else if(telefone[i] == '1'){ | |
out[i] = '1'; tamanho=tamanho+1; | |
} | |
else if(telefone[i] == '2'){ | |
out[i] = '2'; tamanho=tamanho+1; | |
} | |
else if(telefone[i] == '3'){ | |
out[i] = '3'; tamanho=tamanho+1; | |
} | |
else if(telefone[i] == '4'){ | |
out[i] = '4'; tamanho=tamanho+1; | |
} | |
else if(telefone[i] == '5'){ | |
out[i] = '5'; tamanho=tamanho+1; | |
} | |
else if(telefone[i] == '6'){ | |
out[i] = '6'; tamanho=tamanho+1; | |
} | |
else if(telefone[i] == '7'){ | |
out[i] = '7'; tamanho=tamanho+1; | |
} | |
else if(telefone[i] == '8'){ | |
out[i] = '8'; tamanho=tamanho+1; | |
} | |
else if(telefone[i] == '9'){ | |
out[i] = '9'; tamanho=tamanho+1; | |
} | |
else if (telefone[i] == 'A' || telefone[i] == 'B' || telefone[i] == 'C'){ | |
out[i] = '2'; tamanho=tamanho+1; | |
} | |
else if (telefone[i] == 'D' || telefone[i] == 'E' || telefone[i] == 'F'){ | |
out[i] = '3'; tamanho=tamanho+1; | |
} | |
else if (telefone[i] == 'G' || telefone[i] == 'H' || telefone[i] == 'I'){ | |
out[i] = '4'; tamanho=tamanho+1; | |
} | |
else if (telefone[i] == 'J' || telefone[i] == 'K' || telefone[i] == 'L'){ | |
out[i] = '5'; tamanho=tamanho+1; | |
} | |
else if (telefone[i] == 'M' || telefone[i] == 'N' || telefone[i] == 'O'){ | |
out[i] = '6'; tamanho=tamanho+1; | |
} | |
else if (telefone[i] == 'P' || telefone[i] == 'Q' || telefone[i] == 'R' || telefone[i] == 'S'){ | |
out[i] = '7'; tamanho=tamanho+1; | |
} | |
else if (telefone[i] == 'T' || telefone[i] == 'U' || telefone[i] == 'V'){ | |
out[i] = '8'; tamanho=tamanho+1; | |
} | |
else if (telefone[i] == 'W' || telefone[i] == 'X' || telefone[i] == 'Y' || telefone[i] == 'Z'){ | |
out[i] = '9'; tamanho=tamanho+1; | |
} | |
} | |
for(int i=0; i<tamanho; i++){ | |
for(int meme=0; meme<11; meme++){ | |
if(out[i] == valido[meme]) printf("%c", out[i]); | |
} | |
} | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment