Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Практикум 8, Вариант 5, задача III
- //Удалить из сообщения все слова, которые заканчиваются на заданный символ.
- using System;
- using System.Text; //подключили пространство имен для работы с классом StringBuilder
- namespace Hah
- {
- class Program
- {
- static void Main()
- {
- StringBuilder a = new StringBuilder("кол около колокола");
- Console.WriteLine("Дана строка: {0}", a);
- Console.Write("Символ: ");
- char c = char.Parse(Console.ReadLine());
- for (int x = 0; x < a.Length; x++)
- {
- if (a[x] == ' ')
- {
- int j = x;
- int m=j;
- x++;
- while (a[x] != ' ')
- {
- m++;
- }
- if (a[m+1] == c)
- {
- a.Remove(j, m-j);
- }
- }
- }
- Console.WriteLine("\n {0}",a);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement