求2个字串最大个数
用map
string=“”;
ZZZAA
2
ZZ有俩个
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>A
#include<map>
using namespace std;
int main()
{
char s[105];
map<string,int>q;
int n,maxn;
while(cin>>n)
{
cin>>s;
maxn=-1;
q.clear();
string p="",ans1;
for(int i=0;i<n-1;i++)
{
p=p+s[i]+s[i+1];
q[p]++;
int ans=q[p];
if(ans>maxn)
{
maxn=ans;
ans1=p;
}
p="";
}
cout<<ans1<<endl;
}
}