Tp1_soundex.c 904 Bytes
#include <stdio.h>

int minuscule(char ch){
    if ((ch >= 'a') && (ch <= 'z')){
        return 1;
    }else{
        return 0;
    }
}


int majuscule(char ch){
    if ((ch >= 'A') && (ch <= 'Z')){
        return 1;
    }else{
        return 0;
    }
}

int estVoyelle(char ch){
    if(ch == 'a' ||  ch=='e' || ch=='i'|| ch=='o' || ch=='u' || ch=='y' ||ch== 'A' || ch=='E' ||ch== 'I' ||ch== 'O' || ch=='U' || ch=='Y'){
        return 1;
    }
    return 0;
}

void soundexcode(){
    char ch;
    char savech; 
    int nblettre = 4;
    scanf("%c",&ch);
    savech=ch;
    printf("==> %c",ch);
    
    while(nblettre!=1 && (minuscule(ch) || majuscule(ch))){
        scanf("%c",&ch);        
        if (ch != savech && !estVoyelle(ch)){
            savech=ch;
            printf("%c",ch);
           
            nblettre--;
        } 
        savech=ch;
    }
    
}

int main(){
    soundexcode();
}