mirror of
https://github.com/xlucn/PAT.git
synced 2026-02-08 20:11:55 +08:00
22 lines
382 B
C
22 lines
382 B
C
#include <stdio.h>
|
|
#include <ctype.h>
|
|
|
|
int main()
|
|
{
|
|
char c;
|
|
int count[26] = {0}, max = 25;
|
|
|
|
while ((c = getchar()) != EOF && c != '\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;
|
|
}
|