62,254
社区成员
发帖
与我相关
我的任务
分享

string s = "abcdgegeagdccvivio";
for (int i = 97; i <= 122; i++)
{
char c = (char)i;
int counter = 0;
foreach (char cc in s)
{
if (cc == c)
counter++;
if (counter > 2)
break;
}
if (counter == 2)
Response.Write(c);
} string s = "abcdgegeagdccvivio";
for (int i = 97; i <= 122; i++)
{
char c = (char)i;
int counter = 0;
foreach (char cc in s)
{
if (cc == c)
counter++;
}
if (counter == 2)
Response.Write(c);
}
string s=“a,b,c,d,g,e,g,e,a,g,d,c,c,v,i,v,i,o”;
s = s.Replace(",","");
public string f(string s){
List<char> lc = new List<char>();
int count = 0;
List<char>Rl=new List<char>();
foreach (char c in s)
{
lc.Add(c);
}
foreach (char c0 in s)
{
count = 0;
while (lc.Contains(c0))
{
lc.Remove(c0);
count++;
}
if (count == 2)
{
Rl.Add(c0);
}
}
string re=null;
foreach (char item in Rl)
{ re = re + item;}
return re;
}
string str = "abcdgegeagdccvivio";
int[] arr = new int[26];
foreach (char c in str)
{
arr[c - 97]++;
}
for (int i = 0; i < arr.Length;i++ )
{
if (arr[i]==2)
Console.WriteLine(Convert.ToChar(i + 97));
}
string s = "abcdgegeagdccvivio";
public string f(string s){
List<char> lc = new List<char>();
int count = 0;
List<char>Rl=new List<char>();
foreach (char c in s)
{
lc.Add(c);
}
foreach (char c0 in s)
{
count = 0;
while (lc.Contains(c0))
{
lc.Remove(c0);
count++;
}
if (count == 2)
{
Rl.Add(c0);
}
}
string re=null;
foreach (char item in Rl)
{ re = re + item;}
return re;
}
s.GroupBy(c => c).Where(w => w.Count() == 2)