32 lines
745 B
C
32 lines
745 B
C
|
#include<stdio.h>
|
||
|
#include<stdlib.h>
|
||
|
#include<string.h>
|
||
|
|
||
|
#define MAX_LEN 200
|
||
|
|
||
|
int main(int argc, char * argv[]) {
|
||
|
char str[MAX_LEN];
|
||
|
|
||
|
printf("Ligne de texte : ");
|
||
|
fgets(str, MAX_LEN, stdin);
|
||
|
|
||
|
int e_found = 0; //Compte le nombre d'occurence de la lettre 'e'.
|
||
|
int letters_found[255] = {}; //Répertorie les différentes lettres trouvées.
|
||
|
int diff_letter_found = 0; //Compte le nombre de lettre différentes trouvées.
|
||
|
|
||
|
for (int i = 0; i < strlen(str); i++) {
|
||
|
char letter = str[i];
|
||
|
if (letter == 'e') e_found++;
|
||
|
|
||
|
if (letters_found[letter+128] != 1) {
|
||
|
letters_found[letter+128] = 1;
|
||
|
diff_letter_found++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
printf("La ligne contient %d e et %d lettre différente.\n", e_found, diff_letter_found);
|
||
|
|
||
|
return EXIT_SUCCESS;
|
||
|
}
|
||
|
|