Advertisement
Filkolev

Parachute

May 27th, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Parachute
  6. {
  7.     public static void Main()
  8.     {
  9.         List<string> matrix = new List<string>();
  10.  
  11.         string input = Console.ReadLine();
  12.         int row = 0;
  13.         int col = 0;
  14.         bool found = false;
  15.  
  16.         while (input != "END")
  17.         {
  18.             if (input.Contains("o"))
  19.             {
  20.                 col = input.IndexOf("o");
  21.                 found = true;
  22.             }
  23.             else if (!found)
  24.             {
  25.                 row++;
  26.             }
  27.            
  28.             matrix.Add(input);
  29.             input = Console.ReadLine();
  30.         }
  31.  
  32.         while (true)
  33.         {
  34.             row++;
  35.  
  36.             col -= matrix[row].Count(symbol => symbol == '<');
  37.             col += matrix[row].Count(symbol => symbol == '>');
  38.  
  39.             if (matrix[row][col] == '_')
  40.             {
  41.                 Console.WriteLine("Landed on the ground like a boss!");
  42.                 break;
  43.             }
  44.            
  45.             if (matrix[row][col] == '~')
  46.             {
  47.                 Console.WriteLine("Drowned in the water like a cat!");
  48.                 break;
  49.             }
  50.  
  51.             if (matrix[row][col] == '\\'
  52.                 || matrix[row][col] == '/'
  53.                 || matrix[row][col] == '|')
  54.             {
  55.                 Console.WriteLine("Got smacked on the rock like a dog!");
  56.                 break;
  57.             }
  58.         }
  59.  
  60.         Console.WriteLine("{0} {1}", row, col);
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement