#include <string>
#include <map>
#include <vector>
#include <iostream>
#include <stack>
using namespace std;
int main()
{
string tmp;
stack<string> st;
while(cin>>tmp)
{
string s;
for(int i=0;i<tmp.size();i++)
{
if(!isdigit(tmp[i])&&!isalpha(tmp[i]))
continue;
else
{
if(islower(tmp[i]))
{
s+=tmp[i];
}
else
{
s+=tolower(tmp[i]);
}
}
}
st.push(s);
}
map<string,int> ma;
while(!st.empty())
{
string tmp;
tmp=st.top();
if(ma.find(tmp)==ma.end())
ma[tmp]=1;
else
ma[tmp]++;
st.pop();
}
map<string,int>::iterator iter;
int max=-1;
string max1;
for(iter=ma.begin();iter!=ma.end();iter++)
{
if(max<=iter->second)
{
if(iter->second==max){
if(max1>iter->first){
max1=iter->first;}
}
else
max1=iter->first;
max=iter->second;
}
}
cout<<max1<<" "<<max<<endl;
return 0;
}
跪了一个点
1071. Speech Patterns (25)
最新推荐文章于 2022-12-02 15:52:30 发布