注意你写成for(j=i;j<s.size();j++){if( ))}他会一直循环
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n;
cin>>n;
while(n--)
{
string s;
cin>>s;
int max=0,j=0,i=0;
char c;
for(i=0;i<s.size();i++)
{
int count=0;
j=i;
while(j<s.size()&&s[i]==s[j])
{
j++;
count++;
}
if(count>max)
{
max=count;
c=s[i];
}
i=j-1;
}
cout<<c<<' '<<max<<endl;
}
return 0;
}