Advertisement
YavorGrancharov

02.Icarus

Nov 5th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _02.Icarus
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> plane = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  12.  
  13.             int index = int.Parse(Console.ReadLine());
  14.  
  15.             int damage = 1;
  16.  
  17.             string input = Console.ReadLine();
  18.             while (input != "Supernova")
  19.             {
  20.                 string[] tokens = input.Split(' ');
  21.                 string direction = tokens[0];
  22.                 int step = int.Parse(tokens[1]);
  23.  
  24.                 switch (direction)
  25.                 {
  26.                     case "left":
  27.                         for (int i = 0; i < step; i++)
  28.                         {
  29.                             index--;
  30.                             if (index < 0)
  31.                             {
  32.                                 index = plane.Count - 1;
  33.                                 damage++;
  34.                             }
  35.                             plane[index] -= damage;
  36.                         }
  37.                         break;
  38.                     case "right":
  39.                         for (int i = 0; i < step; i++)
  40.                         {
  41.                             index++;
  42.                             if (index > plane.Count - 1)
  43.                             {
  44.                                 index = 0;
  45.                                 damage++;
  46.                             }
  47.                             plane[index] -= damage;
  48.                         }
  49.                         break;
  50.                 }
  51.                 input = Console.ReadLine();
  52.             }
  53.             Console.WriteLine(string.Join(" ", plane));
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement