Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Threading;
- namespace IMJunior
- {
- class Program
- {
- static void Main()
- {
- FilesCheck(new string[] {
- "words.txt",
- "in.txt"
- });
- string[] list = File.ReadAllLines("words.txt");
- string text = File.ReadAllText("in.txt");
- text = Filter(text, list);
- string line = GenerateString(Console.WindowWidth, "-");
- WriteColorLine(line);
- WriteColorLine(text, ConsoleColor.Yellow);
- WriteColorLine(line);
- File.WriteAllText("out.txt", text);
- }
- static void FilesCheck(string[] paths)
- {
- for(int i = 0; i < paths.Length; i++)
- {
- if (!File.Exists(paths[i]))
- {
- Console.WriteLine("Не найден файл - " + paths[i]);
- Console.ReadLine();
- Environment.Exit(1);
- }
- }
- }
- static string Filter(string text, string[] blackList)
- {
- for(int i = 0; i < blackList.Length; i++)
- {
- text = text.Replace(blackList[i],
- GenerateString(blackList[i].Length));
- }
- return text;
- }
- static string GenerateString(int length, string fuller = "#")
- {
- if (fuller.Length == 0)
- {
- return "";
- }
- string mask = "";
- for (int j = 0; j < length; j += fuller.Length)
- {
- mask += fuller;
- }
- mask = mask.Substring(0, length);
- return mask;
- }
- static void WriteColorLine(string message, ConsoleColor color = ConsoleColor.Red)
- {
- ConsoleColor old = Console.ForegroundColor;
- Console.ForegroundColor = color;
- Console.WriteLine(message);
- Console.ForegroundColor = old;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment