Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int Surch(String s, StringBuilder t)
- {
- int i = 0;
- int j = 0;
- int ssize = s.Length;
- int tsize = t.Length;
- while ((i <= (tsize - ssize)) && (j < ssize))
- {
- if (t[i + j] == s[j])
- {
- j++;
- }
- else
- {
- i++;
- j = 0;
- }
- }
- if (j == ssize)
- return i;
- else return -1;
- }
- static void Main(string[] args)
- {
- Console.Write("Enter string: ");
- StringBuilder str = new StringBuilder(Console.ReadLine());
- Console.Write("Enter substring: ");
- String substr = Console.ReadLine();
- while (Surch(substr, str) != -1)
- {
- str.Remove(Surch(substr, str), substr.Length);
- }
- if(str.Length == 0)
- Console.WriteLine("Удалили все симаолы из строки.");
- else Console.WriteLine(str);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement