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;
- using System.Security;
- class Test
- {
- static void Main(string[] args)
- {
- List<char[]> matrix = new List<char[]>();
- while (true)
- {
- string line = Console.ReadLine();
- if (line == "END")
- {
- break;
- }
- matrix.Add(line.ToCharArray());
- }
- char[,] input = new char[matrix.Count, matrix[0].Length];
- for (int i = 0; i < matrix.Count; i++)
- {
- for (int j = 0; j < matrix[0].Length; j++)
- {
- input[i, j] = (char)matrix[i].GetValue(j);
- }
- }
- /*
- char[,] input =
- {
- {'*', '*', '*','*', '*', '*', '*', '*', '*', '*', },
- {'*', '*', '>','*', '*', '*', '*', 'v', '*', '*', },
- {'*', '*', '*','*', '*', '*', '*', '*', '*', '*', },
- {'*', '*', '*','*', '*', '*', '*', '*', '*', '*', },
- {'*', '*', '^','*', '*', '*', '*', '<', '*', '*', },
- {'v', '*', '*','*', '*', '*', '*', '*', '*', '*', },
- };
- */
- char[,] clonedInput = (char[,])input.Clone();
- char specialChar = ' ';
- for (int i = 0; i < clonedInput.GetLength(0); i++)
- {
- for (int j = 0; j < clonedInput.GetLength(1); j++)
- {
- specialChar = clonedInput[i, j];
- switch (specialChar)
- {
- case '>':
- for (int k = j + 1; k < clonedInput.GetLength(1); k++)
- {
- char temp = clonedInput[i, k];
- if (clonedInput[i, k] != '>' && clonedInput[i, k] != '<' &&
- clonedInput[i, k] != 'v' && clonedInput[i, k] != '^')
- {
- clonedInput[i, k] = ' ';
- }
- else
- {
- break;
- }
- }
- break;
- case '<':
- for (int k = j - 1; k > 0; k--)
- {
- if (clonedInput[i, k] != '>' && clonedInput[i, k] != '<' &&
- clonedInput[i, k] != 'v' && clonedInput[i, k] != '^')
- {
- clonedInput[i, k] = ' ';
- }
- else
- {
- break;
- }
- }
- break;
- case 'v':
- for (int k = i + 1; k < clonedInput.GetLength(0); k++)
- {
- if (clonedInput[k, j] != '>' && clonedInput[k, j] != '<' &&
- clonedInput[k, j] != 'v' && clonedInput[k, j] != '^')
- {
- clonedInput[k, j] = ' ';
- }
- else
- {
- break;
- }
- }
- break;
- case '^':
- for (int k = i - 1; k > 0; k--)
- {
- if (clonedInput[k, j] != '>' && clonedInput[k, j] != '<' &&
- clonedInput[k, j] != 'v' && clonedInput[k, j] != '^')
- {
- clonedInput[k, j] = ' ';
- }
- else
- {
- break;
- }
- }
- break;
- default:
- break;
- }
- }
- }
- for (int i = 0; i < clonedInput.GetLength(0); i++)
- {
- Console.Write(@"<p>");
- for (int j = 0; j < clonedInput.GetLength(1); j++)
- {
- Console.Write(SecurityElement.Escape(clonedInput[i, j].ToString()));
- }
- Console.WriteLine(@"</p>");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement