Advertisement
Guest User

Untitled

a guest
May 25th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace PlusRemove
  8. {
  9. class PlusRemove
  10. {
  11. static void Main(string[] args)
  12. {
  13. string input = Console.ReadLine();
  14. List<string> text = new List<string>();
  15. int max = 0;
  16. while (input != "END")
  17. {
  18. text.Add(input);
  19. if (input.Length > max)
  20. {
  21. max = input.Length;
  22. }
  23. input = Console.ReadLine();
  24. }
  25. char[,] first = new char[text.Count, max];
  26. char[,] second = new char[text.Count, max];
  27. for (int row = 0; row < text.Count; row++)
  28. {
  29. string current = text[row];
  30. for (int col = 0; col < max; col++)
  31. {
  32. if (col < current.Length)
  33. {
  34. first[row, col] = Char.ToLower(current[col]);
  35. second[row, col] = current[col];
  36. }
  37. else
  38. {
  39. first[row, col] = ' ';
  40. second[row, col] = ' ';
  41. }
  42. }
  43. }
  44. for (int row = 0; row < first.GetLength(0) - 2; row++)
  45. {
  46. for (int col = 1; col < first.GetLength(1) - 1; col++)
  47. {
  48. if (first[row,col] == first[row+1,col]
  49. && first[row,col] == first[row+2,col]
  50. && first[row,col] == first[row+1,col-1]
  51. && first[row,col] == first[row+1,col+1])
  52. {
  53. second[row, col] = ' ';
  54. second[row + 1, col] = ' ';
  55. second[row + 2, col] = ' ';
  56. second[row + 1, col - 1] = ' ';
  57. second[row + 1, col + 1] = ' ';
  58. }
  59. }
  60. }
  61. PrintMatrix(second);
  62. }
  63.  
  64. private static void PrintMatrix(char[,] matrix)
  65. {
  66. for (int row = 0; row < matrix.GetLength(0); row++)
  67. {
  68. for (int col = 0; col < matrix.GetLength(1); col++)
  69. {
  70. if (matrix[row,col] != ' ')
  71. {
  72. Console.Write(matrix[row,col]);
  73. }
  74. }
  75. Console.WriteLine();
  76. }
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement