백준
[1157] 단어 공부
by Jcoder
2018. 7. 14.
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
map<char, int> m;
string str;
cin >> str;
map<char, int>::iterator iter;
for (int i = 0; i < str.size(); i++)
{
if (str[i] >= 'a')
{
str[i] -= 32;
}
iter = m.find(str[i]);
if (iter != m.end())
m[iter->first] += 1;
else
m[str[i]] = 1;
}
map<char, int>::iterator max = m.begin();
iter = m.begin()++;
for (; iter != m.end(); iter++)
{
if (max->second < iter->second)
max = iter;
}
for (iter = m.begin(); iter != m.end(); iter++)
{
if (max->second == iter->second && max->first != iter->first)
{
cout << "?\n";
return 0;
}
}
cout << max->first << endl;;
return 0;
}