寻找最长子串

if (str == null || str == string.Empty)
{
 printf"Null or empty!!!!\n";
}
int max = 1;
int count = 1;
int number = 0;
char[] theChar=new char[str.Length];
theChar[number] = str[0];
for (int i = 1; i < str.Length; i++)
{
if (str[i] == str[i - 1])
{
count++;
if(max < count)
{
max=count;
number = 0;
theChar[number]=str[i];
}
else if (max == count)
{
number++;
theChar[number] = str[i];
}
}
if (str[i] != str[i - 1])
{
count = 1;
}
}
string[] strArray = new string[number+1];
for (int i = 0; i <= number; i++)
{
strArray[i] = new string(theChar[i], max);
}
return strArray;
}
上一篇:iOS组件化开发一远程私有库的升级(三)


下一篇:iOS组件化开发一本地环境配置(一)