-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolution.cpp
49 lines (41 loc) · 972 Bytes
/
solution.cpp
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
49
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int t, len, m;
char s[200];
char c[27] = "abcdefghijklmnopqrstuvwxyz";
int n[26] = {0};
scanf("%d", &t);
getchar();
for(int i = 1; i <= t; i++) {
gets(s);
for(int j = 0; j < 26; j++) {
n[j] = 0;
}
m = 0;
len = strlen(s);
for(int j = 0; j < len; j++) {
if(s[j] >= 'A' && s[j] <= 'Z') {
n[s[j]-65]++;
if(n[s[j]-65] > m) {
m = n[s[j]-65];
}
} else if(s[j] >= 'a' && s[j] <= 'z') {
n[s[j]-97]++;
if(n[s[j]-97] > m) {
m = n[s[j]-97];
}
}
}
for(int j = 0; j < 26; j++) {
if(n[j] == m) {
printf("%c", c[j]);
}
}
printf("\n");
}
return 0;
}