34 lines
748 B
C
34 lines
748 B
C
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
#pragma GCC optimize("Ofast,inline")
|
||
|
#define MAXLEN 100
|
||
|
|
||
|
int main(void) {
|
||
|
char string[MAXLEN];
|
||
|
scanf("%s", string);
|
||
|
|
||
|
char hashA[26] = {};
|
||
|
char hasha[26] = {};
|
||
|
|
||
|
// Store values to hash table
|
||
|
for (int i = 0, j = strlen(string); i < j; i++) {
|
||
|
if (string[i] >= 'A' && string[i] <= 'Z') {
|
||
|
hashA[string[i] - 'A']++;
|
||
|
} else if (string[i] >= 'a' && string[i] <= 'z') {
|
||
|
hasha[string[i] - 'a']++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
for (int i = 0; i < 26; i++) {
|
||
|
if (hashA[i]) {
|
||
|
printf("The character %c has presented %i times.\n", i + 'A', hashA[i]);
|
||
|
}
|
||
|
}
|
||
|
for (int i = 0; i < 26; i++) {
|
||
|
if (hasha[i]) {
|
||
|
printf("The character %c has presented %i times.\n", i + 'a', hasha[i]);
|
||
|
}
|
||
|
}
|
||
|
return 0;
|
||
|
}
|