双指针
- 怎么判断下一个字符和当前不一样——
s[j] = s[i]
- 怎么记录并输出当前长度最大字母——
if
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
while (n -- )
{
string s;
cin >> s;
char c;
int res = 0;
for (int i = 0; i < s.size(); i ++ )
{
int j = i;
while (j < s.size() && s[i] == s[j]) j ++ ;
if (j - i > res) c = s[i], res = j - i;
i = j - 1;
}
cout << c << ' ' << res << endl;
}
}