C++ 代码
#include <bits/stdc++.h>
using namespace std;
int main()
{
string a;
char c;
int t,sum = 1,maxn = 1;
cin>>t;
while(t--)
{
cin >> a;
sum = 1;
maxn = 1;
for(int i= 0 ; i < a.size()-1; i ++)
{
if(a[i] == a[i+1])
{
sum ++;
}
if(sum > maxn)
{
maxn = sum;
c = a[i];
}
if(a[i] != a[i+1])
{
sum = 1;
}
}
if(maxn == 1)
cout << a[0] << " " << maxn << endl;
else
cout << c <<" "<< maxn << endl;
}
return 0;
}