public static string shita1(string st1)
{
string st2 = "", stemp = st1;
int i;
for(i=0; i<stemp.Length; i++)
{
if (stemp.IndexOf("cbc") == i)
{
i += 2 ;
stemp = "";
stemp = st1.Substring(i);
i = 0;
}
else
st2 = st2 + stemp[i];
}
return st2;
}
static void Main(string[] args)
{
string st1;
Console.WriteLine("enter one string:");
st1 = Console.ReadLine();
Console.WriteLine(shita1(st1));
}
}
我接到了我的大学一challange删除一组字符,则challange是从字符串中移动任何“CBC”字......使用的indexOf(C#)从字符串
这是我的代码......当我只使用一个“cbc”时,它可以工作,但是当我使用其中的2个时,它可以帮助... :)
'string result = input.replace(“cbc”,string.Empty);'? –