Advertisement
Ochkasty_Dino

Practicum8-III-5

Nov 18th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Text;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. namespace ConsoleApp3
  8. {
  9.     class Program4
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Please enter the symbol - ");
  14.             char sym = char.Parse(Console.ReadLine());
  15.             using (StreamReader fileIn = new StreamReader("C:/Users/belousaa/Documents/Visual Studio 2017/pract8.txt", Encoding.GetEncoding(1251)))
  16.             {
  17.                 using (StreamWriter fileOut = new StreamWriter("C:/Users/belousaa/Documents/Visual Studio 2017/out.txt", false))
  18.                 {
  19.                     string[] words = fileIn.ReadToEnd().Split(new char[] { ' ', '!', '.', ',', '?', '-', ':' }, StringSplitOptions.RemoveEmptyEntries);
  20.                     foreach (var word in words)
  21.                     {
  22.                          if (word[word.Length-1] != sym)
  23.                             {
  24.                                 fileOut.Write(word + " ");
  25.                                
  26.                             }
  27.  
  28.                     }
  29.                 }
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement