3. Substring - не вярно решение в презентацията!
string key = Console.ReadLine();
string text = Console.ReadLine();
int index = text.IndexOf(key);
while (index != -1)
{
text = text.Remove(index, key.Length);
index = text.IndexOf(key);
}
Console.WriteLine(text);
Моля дайте ми правилно решение на задачата! Като некой глупак и аз се въртя в тоя луп! и не мога да намеря правилно решение!
Ето го условието на зада4ата:
On the first line you will receive a string. On the second line you will receive a second string. Write a program that removes all of the occurrences of the first string in the second until there is no match. At the end print the remaining string.
Input
Output
Comment
ice
kicegiciceeb
kgb
We remove ice once and we get "kgiciceeb"
We match "ice" one more time and we get "kgiceb"
There is one more match. The finam result is "kgb"
4етох в интернет, и изглежда трябва да се ползва: while (index != -1)
"All the above variations returns -1 if the specified char/substring is not found in the particular String."