如题,C# Code如下:
public static string[] GetBiggestString(string str)
{
if (str == null || str == string.Empty)
{
throw new Exception("Null or empty!!!!");
}
var max = 1;
var count = 1;
var 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;
}