5eb7fe63
Vincent Benoist
TP de C
|
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
|
#include <stdio.h>
int chiffre(char ch){
if ((ch >= '0') && (ch <= '9')){
return 1;
}else{
return 0;
}
}
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;
}
}
void analysePhrase(int* nbChar, int* nbChiffre, int* nbMin, int * nbMaj){
char c;
scanf("%c",&c);
while(c!='.'){
if(chiffre(c)==1){
*nbChiffre = *nbChiffre+1;
}else if(minuscule(c)==1){
*nbMin=*nbMin+1;
}else if(majuscule(c)==1){
*nbMaj=*nbMaj+1;
}
scanf("%c",&c);
*nbChar=*nbChar+1;
}
}
int main(){
int nbChar=0,nbChiffre=0,nbMin=0, nbMaj =0;
printf("Char: %d Chiffre: %d nbMin: %d nbMaj: %d\n",nbChar,nbChiffre,nbMin, nbMaj);
analysePhrase(&nbChar,&nbChiffre,&nbMin,&nbMaj);
printf("Char: %d Chiffre: %d nbMin: %d nbMaj: %d\n",nbChar,nbChiffre,nbMin, nbMaj);
return 0;
}
|