CodeTP1Bis.c
1.15 KB
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
#include <stdio.h>
#include <ctype.h>
int chiffre(char ch) {
int rep;
if (isdigit(ch)){
rep =1;}
else{
rep=0;
}
return rep;
}
int minuscule(char ch) {
int rep;
char x, y;
x = 'a';
y = 'z';
if (ch<x || ch>y){
rep =0;}
else{
rep=1;
}
return rep;
}
int majuscule(char ch) {
int rep;
char x, y;
y = 'Z';
x = 'A';
if (ch<x || ch>y){
rep =0;}
else{
rep=1;
}
return rep;
}
void analysePhrase(int *pMaj, int *pMin, int *pChi, int *pCar) {
char lettre;
printf("Saisir une phrase se terminant par un point : ");
scanf("%c", &lettre);
*pMaj=0;
*pMin=0;
*pChi=0;
*pCar=0;
while (lettre != '.') {
*pMaj= *pMaj + majuscule(lettre);
*pMin= *pMin + minuscule(lettre);
*pChi= *pChi + chiffre(lettre);
*pCar= *pCar + 1;
scanf("%c", &lettre);
}
}
int main() {
int Nmaj, Nmin, Nchi, Ncar;
analysePhrase(&Nmaj, &Nmin, &Nchi, &Ncar);
printf("Phrase de %d charactère(s), contenant %d majuscule(s), %d minuscule(s) et %d chiffre(s)", Ncar, Nmaj, Nmin, Nchi);
return(0);
}