Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            char[,] matrix = new char[n, n];

            FillTheMatrix(matrix);
            Postiton position = GetPosition(matrix);

            while (true)
            {
                var command = Console.ReadLine();
                if (command == "up")
                {
                    position.Row--;
                }
                else if (command == "down")
                {
                    position.Row++;
                }
                else if (command == "left")
                {
                    position.Col--;
                }
                else if (command == "right")
                {
                    position.Col++;
                }

                if (matrix[position.Row, position.Col] == 'E')
                {
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private string SetHint(string target, string server)
        {
            Postiton position = WhereHint(target);

            target = target.Remove(position.sti, position.eni - position.sti).Insert(position.sti, server);

            return(target);
        }
Ejemplo n.º 3
0
        static Postiton GetPosition(char[,] matrix)
        {
            Postiton position = null;

            for (int row = 0; row < matrix.GetLength(0); row++)
            {
                for (int col = 0; col < matrix.GetLength(1); col++)
                {
                    if (matrix[row, col] == 'S')
                    {
                        position = new Postiton(row, col);
                    }
                }
            }
            return(position);
        }
Ejemplo n.º 4
0
        private string GetHint(string target)
        {
            Postiton position = WhereHint(target);

            return(target.Substring(position.sti, position.eni - position.sti));
        }