-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2_Lab01_4.c
More file actions
48 lines (46 loc) · 876 Bytes
/
2_Lab01_4.c
File metadata and controls
48 lines (46 loc) · 876 Bytes
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
45
46
47
48
#include <stdio.h>
#include <string.h>
int main(void)
{
int i, j, max, result = 0, len;
char arr[1000000];
int cnt[26] = { 0, };
int select = 0;
scanf("%s", arr);
len = strlen(arr);
for (i = 'a'; i <= 'z'; i++)
{
for (j = 0; j < len; j++)
{
if (i == arr[j])
cnt[i - 'a']++;
}
}
for (i = 'A'; i <= 'Z'; i++)
{
for (j = 0; j < len; j++)
{
if (i == arr[j])
cnt[i - 'A']++;
}
}
max = cnt[0];
for (i = 1; i < 26; i++)
{
if (max < cnt[i])
{
max = cnt[i];
select = i;
}
}
for (i = 0; i < 26; i++)
{
if (max == cnt[i])
result++;
}
if (result > 1)
printf("?\n");
else
printf("%c", select + 'A');
return 0;
}