Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PlusRemove
- {
- class PlusRemove
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- List<string> text = new List<string>();
- int max = 0;
- while (input != "END")
- {
- text.Add(input);
- if (input.Length > max)
- {
- max = input.Length;
- }
- input = Console.ReadLine();
- }
- char[,] first = new char[text.Count, max];
- char[,] second = new char[text.Count, max];
- for (int row = 0; row < text.Count; row++)
- {
- string current = text[row];
- for (int col = 0; col < max; col++)
- {
- if (col < current.Length)
- {
- first[row, col] = Char.ToLower(current[col]);
- second[row, col] = current[col];
- }
- else
- {
- first[row, col] = ' ';
- second[row, col] = ' ';
- }
- }
- }
- for (int row = 0; row < first.GetLength(0) - 2; row++)
- {
- for (int col = 1; col < first.GetLength(1) - 1; col++)
- {
- if (first[row,col] == first[row+1,col]
- && first[row,col] == first[row+2,col]
- && first[row,col] == first[row+1,col-1]
- && first[row,col] == first[row+1,col+1])
- {
- second[row, col] = ' ';
- second[row + 1, col] = ' ';
- second[row + 2, col] = ' ';
- second[row + 1, col - 1] = ' ';
- second[row + 1, col + 1] = ' ';
- }
- }
- }
- PrintMatrix(second);
- }
- private static void PrintMatrix(char[,] matrix)
- {
- for (int row = 0; row < matrix.GetLength(0); row++)
- {
- for (int col = 0; col < matrix.GetLength(1); col++)
- {
- if (matrix[row,col] != ' ')
- {
- Console.Write(matrix[row,col]);
- }
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement