Advertisement
Guest User

Untitled

a guest
May 21st, 2015
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.55 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. using System.Security;
  7.  
  8.  
  9. class Test
  10. {
  11.     static void Main(string[] args)
  12.     {
  13.         List<char[]> matrix = new List<char[]>();
  14.  
  15.         while (true)
  16.         {
  17.             string line = Console.ReadLine();
  18.  
  19.             if (line == "END")
  20.             {
  21.                 break;
  22.             }
  23.  
  24.             matrix.Add(line.ToCharArray());
  25.         }
  26.        
  27.         char[,] input = new char[matrix.Count, matrix[0].Length];
  28.  
  29.         for (int i = 0; i < matrix.Count; i++)
  30.         {
  31.             for (int j = 0; j < matrix[0].Length; j++)
  32.             {
  33.                 input[i, j] = (char)matrix[i].GetValue(j);
  34.             }
  35.         }
  36.  
  37.         /*
  38.         char[,] input =
  39.             {
  40.                 {'*', '*', '*','*', '*', '*', '*', '*', '*', '*', },
  41.                 {'*', '*', '>','*', '*', '*', '*', 'v', '*', '*', },
  42.                 {'*', '*', '*','*', '*', '*', '*', '*', '*', '*', },
  43.                 {'*', '*', '*','*', '*', '*', '*', '*', '*', '*', },
  44.                 {'*', '*', '^','*', '*', '*', '*', '<', '*', '*', },
  45.                 {'v', '*', '*','*', '*', '*', '*', '*', '*', '*', },
  46.             };
  47.         */
  48.         char[,] clonedInput = (char[,])input.Clone();
  49.  
  50.         char specialChar = ' ';
  51.  
  52.         for (int i = 0; i < clonedInput.GetLength(0); i++)
  53.         {
  54.             for (int j = 0; j < clonedInput.GetLength(1); j++)
  55.             {
  56.                 specialChar = clonedInput[i, j];
  57.                 switch (specialChar)
  58.                 {
  59.                     case '>':
  60.  
  61.                         for (int k = j + 1; k < clonedInput.GetLength(1); k++)
  62.                         {
  63.  
  64.                             char temp = clonedInput[i, k];
  65.  
  66.                             if (clonedInput[i, k] != '>' && clonedInput[i, k] != '<' &&
  67.                                 clonedInput[i, k] != 'v' && clonedInput[i, k] != '^')
  68.                             {
  69.                                 clonedInput[i, k] = ' ';
  70.  
  71.                             }
  72.                             else
  73.                             {
  74.                                 break;
  75.                             }
  76.  
  77.                         }
  78.  
  79.                         break;
  80.                     case '<':
  81.  
  82.                         for (int k = j - 1; k > 0; k--)
  83.                         {
  84.                             if (clonedInput[i, k] != '>' && clonedInput[i, k] != '<' &&
  85.                                 clonedInput[i, k] != 'v' && clonedInput[i, k] != '^')
  86.                             {
  87.                                 clonedInput[i, k] = ' ';
  88.  
  89.                             }
  90.                             else
  91.                             {
  92.                                 break;
  93.                             }
  94.                         }
  95.  
  96.                         break;
  97.                     case 'v':
  98.  
  99.                         for (int k = i + 1; k < clonedInput.GetLength(0); k++)
  100.                         {
  101.                             if (clonedInput[k, j] != '>' && clonedInput[k, j] != '<' &&
  102.                                 clonedInput[k, j] != 'v' && clonedInput[k, j] != '^')
  103.                             {
  104.                                 clonedInput[k, j] = ' ';
  105.  
  106.                             }
  107.                             else
  108.                             {
  109.                                 break;
  110.                             }
  111.                         }
  112.  
  113.                         break;
  114.                     case '^':
  115.                         for (int k = i - 1; k > 0; k--)
  116.                         {
  117.                             if (clonedInput[k, j] != '>' && clonedInput[k, j] != '<' &&
  118.                                 clonedInput[k, j] != 'v' && clonedInput[k, j] != '^')
  119.                             {
  120.                                 clonedInput[k, j] = ' ';
  121.  
  122.                             }
  123.                             else
  124.                             {
  125.                                 break;
  126.                             }
  127.                         }
  128.  
  129.                         break;
  130.                     default:
  131.                         break;
  132.                 }
  133.             }
  134.  
  135.         }
  136.  
  137.  
  138.         for (int i = 0; i < clonedInput.GetLength(0); i++)
  139.         {
  140.             Console.Write(@"<p>");
  141.             for (int j = 0; j < clonedInput.GetLength(1); j++)
  142.             {
  143.                 Console.Write(SecurityElement.Escape(clonedInput[i, j].ToString()));
  144.             }
  145.             Console.WriteLine(@"</p>");
  146.         }
  147.  
  148.  
  149.     }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement