Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int telSwitch(char chr) {
- if(isdigit(chr))
- return chr - '0';
- int aux = (int) chr;
- if(aux >= 65 && aux <= 67)
- return 2;
- else if(aux >= 68 && aux <= 70)
- return 3;
- else if(aux >= 71 && aux <= 73)
- return 4;
- else if(aux >= 74 && aux <= 76)
- return 5;
- else if(aux >= 77 && aux <= 79)
- return 6;
- else if(aux >= 80 && aux <= 83)
- return 7;
- else if(aux >= 84 && aux <= 86)
- return 8;
- else if(aux >= 87 && aux <= 90)
- return 9;
- return -1;
- }
- int main(void) {
- char Telefones[1024][1024];
- int i, j;
- for(i = 0; i < (1024); i++)
- strcpy(Telefones[i], "");
- i = 0;
- while(1) {
- char Telaux[1024];
- scanf("%s", Telaux);
- if(feof(stdin))
- break;
- strcpy(Telefones[i], Telaux);
- i++;
- }
- for(i = 0; i < (1024); i++) {
- if(strcmp(Telefones[i], "") == 0)
- break;
- for(j = 0; j < strlen(Telefones[i]); j++) {
- char currentChar = Telefones[i][j];
- if(currentChar == '-')
- printf("-");
- else
- printf("%d", telSwitch(currentChar));
- if((j+1) == strlen(Telefones[i]))
- printf("\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement