1071 Speech Patterns(25 分)
程序员文章站
2024-02-15 17:37:41
...
#include<bits/stdc++.h>
using namespace std;
map<string,int>mp;
string s;
int main()
{
getline(cin,s);
string temp="";
for(int i=0;i<s.length();i++)
{
if(isalnum(s[i]))
{
s[i]=tolower(s[i]);
temp+=s[i];
}
if(!isalnum(s[i])||i==s.length()-1)
{
if(temp.size())mp[temp]++;
temp="";
}
}
int maxtime=0;
string ans;
for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
{
if(it->second>maxtime)maxtime=it->second,ans=it->first;
}
cout<<ans<<" "<<maxtime;
return 0;
}