Blame view

Soundex.c 1.19 KB
b4fe7a20   acuvelie   Ensemble des TP d...
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  #include <stdio.h>
  
  void LireChar(char* pc){
      scanf("%c", pc);
  }
  
  int EstCarac(char n){
      int res;
      if ((n >= 'A' && n <= 'Z')||(n >= 'a' && n <= 'z' )){
           res = 1;
      }
      else{
           res = 0;
      }
      return(res);
  }
  
  int EstVoyelle(char n){
      int res;
      if (n == 'a' || n == 'e' || n == 'i' || n == 'o' || n == 'u' || n == 'y' || n == 'A' || n == 'E' || n == 'I' || n == 'O' ||n == 'U' ||n == 'Y'){
            res = 1;
      }
      else{
            res = 0;
      }
      return(res);
  }
  
  
  int main(){
      
      char c, stock;
      int j=0,resC, resV;
      printf("Saisissez votre nom : ");
      LireChar(&c);
      resC = EstCarac(c);
      
      if(resC == 1){
          printf("Code Soundex : %c",c);
          j= j+1;
          stock = c;
      }
          
      else {
          printf("Nom incorrect !");
      }
      
      
      while(j < 4 && resC != 0){
          
          LireChar(&c);
          resC = EstCarac(c);
          resV = EstVoyelle(c);
          
          if(resC == 1 && resV == 0 && c != stock){
              printf("%c", c);
              j=j+1;
              stock=c;
          }
      
      }
      printf("\n");
      return(0);
  }