-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1157.cpp
More file actions
38 lines (33 loc) · 694 Bytes
/
1157.cpp
File metadata and controls
38 lines (33 loc) · 694 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
#include <iostream>
#include <cstring>
using namespace std;
int main(){
int result[26];
memset(result, 0, sizeof(result));
int answer=0;
string str; cin>>str;
for(int i=0; i<str.length(); i++){
char c = str[i];
if('a'<=c && c<='z'){
result[c-'a']++;
}
else{
result[c-'A']++;
}
}
int mx=0;
int mxNum=0;
for(int i=0; i<26; i++){
if(mx<result[i]){
mx=result[i];
mxNum=i;
}
}
int cnt=0;
for(int i=0; i<26; i++){
if(mx==result[i]) cnt++;
}
if(cnt>1) cout<<"?"<<endl;
else cout<<(char)(mxNum+'A')<<endl;
return 0;
}