B1071 Speech Patterns (25分)
//双指针取单词
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#define lowbit(i)((i)&(-i))
using namespace std;
typedef long long ll;
const int MAX=3e5+10;
const int INF=0x3f3f3f3f;
const int MOD=1000000007;
const int SQR=632;//633块,632个
string s;
map<string,int>mp;
bool check(char &str)
{
if((str>='a'&&str<='z')||(str>='0'&&str<='9'))
return true;
else if(str>='A'&&str<='Z')
{
str+=32;
return true;
}
return false;
}
int main()
{
getline(cin,s);
for(int i=0;i<s.size();i++)
{
int j=i;
string temp="";
if(check(s[j]))
{
while(check(s[j])&&j<s.size())
{
temp+=s[j];
j++;
}
mp[temp]++;
i=j;
}
}
string temp;
int maxnum=0;
for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
{
if(it->second>maxnum)
{
maxnum=it->second;
temp=it->first;
}
}
cout<<temp<<" "<<maxnum<<endl;
return 0;
}











网友评论