#include<iostream>
#include <string.h>
using namespace std;
int main()
{
int cases,max[100];
cout<<"输入测试数据个数:"<<endl;
cin>>cases;
for(int i=0;i<cases;i++)
{
char a[100];
cin>>a;
int count=1;
int len=strlen(a);
for(int j=0;j<len;j++)
{
if(a[j]!=a[j+1])
{
if(count>max[i])
{
max[i]=count;
count=1;
}
}
else
{
count++;
}
}
}
for(int k=0;k<cases;k++)
{
cout<<max[k]<<endl;
}
return 0;
}
给你多组字符串,只包含大写字母,求同一字母连续出现的最大次数
最新推荐文章于 2024-01-04 13:00:00 发布