mirror of
https://github.com/xlucn/PAT.git
synced 2026-10-03 00:23:15 +08:00
22 lines
417 B
C
22 lines
417 B
C
#include <stdio.h>
|
|
#include <ctype.h>
|
|
|
|
int main()
|
|
{
|
|
char c;
|
|
int count[26] = {0}, max = 25;
|
|
|
|
while((c = getchar()) != '\n')
|
|
if(isalpha(c))
|
|
count[tolower(c) - 'a']++;
|
|
|
|
/* find forward from end in case there are multiple maximums */
|
|
for(int i = 25; i >= 0; i--)
|
|
if(count[i] >= count[max])
|
|
max = i;
|
|
|
|
printf("%c %d", max + 'a', count[max]);
|
|
|
|
return 0;
|
|
}
|