-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path499.c
42 lines (37 loc) · 918 Bytes
/
499.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
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int isLetter(char c)
{
return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z';
}
char counter[0x7F];
int main(int argc, char const *argv[])
{
char line[0xFF];
char *p;
int i, max;
while(fgets(line, 0xFF, stdin))
{
memset(counter, 0, sizeof(char) * 0x7F);
max = 0;
p = &line[0];
for(; *p; ++p)
{
if(isLetter(*p))
{
++counter[*p];
}
}
for(i = 'A'; i <= 'Z'; ++i)
if(counter[i] > max) max = counter[i];
for(i = 'a'; i <= 'z'; ++i)
if(counter[i] > max) max = counter[i];
for(i = 'A'; i <= 'Z'; ++i)
if(counter[i] == max) printf("%c", i);
for(i = 'a'; i <= 'z'; ++i)
if(counter[i] == max) printf("%c", i);
printf(" %d\n", max);
}
return 0;
}