Solução: Problema da escrita no celular (Cátia Souza)

From AdonaiMedrado.Pro.Br
Revision as of 12:27, 1 April 2009 by 200.17.147.2 (Talk) (New page: <code lang="c"> #include <stdio.h> #include <stdlib.h> int EhNumero(char num){ char Numeros[] = {'2','3','4','5','6','7','8','9'}; int i; for(i=0;i<=7;i++){ if(num==...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#include <stdio.h>
#include <stdlib.h>
 
int EhNumero(char num){
    char Numeros[] = {'2','3','4','5','6','7','8','9'};
    int i;
 
    for(i=0;i<=7;i++){
        if(num==Numeros[i]){
            return num;
        }
    }
    return -1;
 
}
 
int main(int argc, char** argv) {
    char Teclas[]={'2','a','b','c','3','d','e','f','4','g','h','i','5','j','k','l','6','m','n','o','7','p','q','r','s','8','t','u','v','9','w','x','y','z'};
    char numero;
    char palavra[30];
    int i,count=0, casou,j;
    gets(palavra);
 
    for(i=0; i< strlen(palavra);i++){
        casou=0;
        for(j=0;j<=34 && (casou!=1);j++){
             if(EhNumero(Teclas[j])!=-1){
                numero=Teclas[j];
                count=0;
            }
            if(palavra[i] != Teclas[j]){
                count++;
            }
            else{
                casou=1;
                printf("#%c=%d\n",numero,count);
            }
        }
    }
    return (EXIT_SUCCESS);
}