Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 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.  
  7. namespace ConsoleApp1
  8. {
  9.     public class Program
  10.     {
  11.         public static void Main(string[] args)
  12.         {
  13.             int[] planes = Array.ConvertAll(Console.ReadLine().Split(' ').ToArray(), int.Parse);
  14.             int startingPosition = int.Parse(Console.ReadLine());
  15.             int damage = 1;
  16.             string[] temp;
  17.             do
  18.             {
  19.                 temp = Console.ReadLine().Split(' ').ToArray();
  20.                 if (temp[0] == "Supernova") break;
  21.                 string direction = temp[0];
  22.                 int steps = int.Parse(temp[1]);
  23.  
  24.                 if (direction == "left")
  25.                 {
  26.                     for (int i = steps; i > 0; i--)
  27.                     {
  28.                         startingPosition--;
  29.                         if (startingPosition < 0)
  30.                         {
  31.                             startingPosition = planes.Length;
  32.                             damage++;
  33.                         }
  34.                         planes[startingPosition] -= damage;
  35.  
  36.                     }
  37.                 }
  38.                 else if (direction == "right")
  39.                 {
  40.                     for (int i = steps; i > 0; i--)
  41.                     {
  42.                         startingPosition++;
  43.                         if (startingPosition >= planes.Length)
  44.                         {
  45.                             startingPosition = 0;
  46.                             damage++;
  47.                         }
  48.                         planes[startingPosition] -= damage;
  49.                     }
  50.                 }
  51.             }
  52.             while (temp[1] != "Supernova");
  53.            
  54.             Console.WriteLine(String.Join("; ", planes));
  55.  
  56.             Console.ReadKey();
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement