borko9696

Untitled

Oct 9th, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.12 KB | None | 0 0
  1. namespace Problem_1___Plus_Remove
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.  
  6.     internal class PlusRemove
  7.     {
  8.         private static void Main()
  9.         {
  10.             List<char[]> inputList = new List<char[]>();
  11.             List<char[]> resultList = new List<char[]>();
  12.  
  13.             string line = Console.ReadLine();
  14.  
  15.             while (line != "END")
  16.             {
  17.                 inputList.Add(line.ToCharArray());
  18.  
  19.                 line = Console.ReadLine();
  20.             }
  21.  
  22.             for (int i = 0; i < inputList.Count; i++)
  23.             {
  24.                 char[] temp = new char[inputList[i].Length];
  25.                 for (int j = 0; j < inputList[i].Length; j++)
  26.                 {
  27.                     temp[j] = inputList[i][j];
  28.                 }
  29.                 resultList.Add(temp);
  30.             }
  31.  
  32.             for (int row = 1; row < inputList.Count - 1; row++)
  33.             {
  34.                 for (int col = 1; col < inputList[row].Length - 1; col++)
  35.                 {
  36.                     if (col < inputList[row - 1].Length && col < inputList[row + 1].Length)
  37.                     {
  38.                         if (char.ToLower(inputList[row][col]) == char.ToLower(inputList[row][col - 1])
  39.                             && char.ToLower(inputList[row][col]) == char.ToLower(inputList[row][col + 1])
  40.                             && char.ToLower(inputList[row][col]) == char.ToLower(inputList[row - 1][col])
  41.                             && char.ToLower(inputList[row][col]) == char.ToLower(inputList[row + 1][col]))
  42.                         {
  43.                             resultList[row][col] =
  44.                                 resultList[row][col - 1] =
  45.                                 resultList[row][col + 1] = resultList[row - 1][col] = resultList[row + 1][col] = '\0';
  46.                         }
  47.                     }
  48.                 }
  49.             }
  50.  
  51.             for (int i = 0; i < resultList.Count; i++)
  52.             {
  53.                 string result = new string(resultList[i]);
  54.                 result = result.Replace("\0", "");
  55.                 Console.WriteLine(result);
  56.             }
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment