Tp1_soundex.c
904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#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();
}