当前位置: 移动技术网 > IT编程>开发语言>.net > 编程复习1:寻找字符串中最大出现次数的所有字母

编程复习1:寻找字符串中最大出现次数的所有字母

2018年01月30日  | 移动技术网IT编程  | 我要评论

欢乐课程第三季,武隆县教育信息网,假招聘赚回扣获刑

题目输入输出

"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

}

}
}

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网