forked from thantrieu/LearnC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bai5.5.c
44 lines (38 loc) · 858 Bytes
/
bai5.5.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
#include <stdio.h>
#include <string.h>
void countLetters(char *c) {
int i;
int size = strlen(c);
int b[97+26] = {0};
for(i = 0; i< size; i++){
char w = tolower(c[i]);
b[w]++;
}
for(i = 97; i< 123; i++){
printf("%c: %d\n", (char)i, b[i]);
}
}
void countLettersA(char *c) {
int i;
int size = strlen(c);
int b[97+26] = {0};
for(i = 0; i< size; i++){
b[c[i]]++;
}
for(i = 65; i< 91; i++){
printf("%c: %d\n", (char)i, b[i]);
}
for(i = 97; i< 123; i++){
printf("%c: %d\n", (char)i, b[i]);
}
}
int main() {
char x[100];
fgets(x, 99, stdin);
puts("Dem ki tu co phan biet chu hoa, chu thuong: ");
countLettersA(x);
printf("\n\n");
puts("Dem ki tu khong phan biet chu hoa, chu thuong: ");
countLetters(x);
return 0;
}