VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > Python基础教程 >
  • C#教程之寻找字符串中最大出现次数的所有字母

题目输入输出

"this is a sentence" => [t, h, i, s, i, s, a, s, e, n, t, e, n, c, e]
"thiis iss a senntencee" => [i, s, n, e]
"thiisss iss a senntttenceee" => [s, t, e]
"thiisss iss a sennnntttenceee" => [n]

solution:

using system;
class program
{
static void Main(string[] args)
{
string input='xxxx';
string[] output=test(input);
Console.WriteLine(output);

}

public string[] findMax (string s){
string[] all=s.divide();
int max=1;
int current=1;
bool active=false;
for (int i=1;i++i<len){
if all[i]=all[i-1] && active
current+=1;
else if all[i]=all[i-1]
active=!active;
current+=1;
else if active
active=!active
if current<max
max=current
current=1

}

current=1;
active=false;
string[] output=new string[];
for (int i=1;i++;i<len ){
if all[i]=all[i-1] && active
current+=1;
else if all[i]=all[i-1]
active=!active;
current+=1;
else if active
active=!active
if current==max
output.add(all[i-1])
current=1

}

}
}


相关教程