Advertisement
Guest User

Untitled

a guest
May 25th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 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 P_10_PlusRemove
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<string> arr = new List<string> { };
  14. string input = Console.ReadLine();
  15. string maxLenght = string.Empty;
  16. while(!input.Contains("END"))
  17. {
  18. arr.Add(input);
  19. if(input.Length>maxLenght.Length)
  20. {
  21. maxLenght = input;
  22. }
  23. input = Console.ReadLine();
  24. }
  25. char[,] exponat = new char[arr.Count, maxLenght.Length];
  26. char[,] result = new char[arr.Count, maxLenght.Length];
  27. for (int row = 0; row < arr.Count; row++)
  28. {
  29. string currString = arr[row];
  30. for (int col = 0; col < maxLenght.Length; col++)
  31. {
  32. if(col<currString.Length)
  33. {
  34. exponat[row, col] =Char.ToUpper(currString[col]);
  35. result[row, col] = currString[col];
  36. }
  37. else
  38. {
  39. exponat[row, col] = ' ';
  40. result[row, col] = ' ';
  41. }
  42. }
  43. }
  44. for (int row = 0; row < arr.Count-2; row++)
  45. {
  46. for (int col = 1; col < maxLenght.Length-1; col++)
  47. {
  48. if(exponat[row,col]==exponat[row+1,col]&&exponat[row,col]==exponat[row+2,col]&&exponat[row,col]==exponat[row+1,col-1]&&exponat[row,col]==exponat[row+1,col+1])
  49. {
  50. result[row, col] = ' ';
  51. result[row+1, col] = ' ';
  52. result[row+2, col] = ' ';
  53. result[row+1, col-1] = ' ';
  54. result[row+1, col+1] = ' ';
  55. }
  56. }
  57. }
  58. Print(result, arr.Count, maxLenght.Length);
  59.  
  60. }
  61. static void Print (Char[,]matrix,int rowLenght,int colLenght)
  62. {
  63. for (int row = 0; row < rowLenght; row++)
  64. {
  65. for (int col = 0; col < colLenght; col++)
  66. {
  67. if(matrix[row,col]!=' ')
  68. {
  69. Console.Write(matrix[row, col]);
  70. }
  71. }
  72. Console.WriteLine();
  73. }
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement