Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- int[] planes = Array.ConvertAll(Console.ReadLine().Split(' ').ToArray(), int.Parse);
- int startingPosition = int.Parse(Console.ReadLine());
- int damage = 1;
- string[] temp;
- do
- {
- temp = Console.ReadLine().Split(' ').ToArray();
- if (temp[0] == "Supernova") break;
- string direction = temp[0];
- int steps = int.Parse(temp[1]);
- if (direction == "left")
- {
- for (int i = steps; i > 0; i--)
- {
- startingPosition--;
- if (startingPosition < 0)
- {
- startingPosition = planes.Length;
- damage++;
- }
- planes[startingPosition] -= damage;
- }
- }
- else if (direction == "right")
- {
- for (int i = steps; i > 0; i--)
- {
- startingPosition++;
- if (startingPosition >= planes.Length)
- {
- startingPosition = 0;
- damage++;
- }
- planes[startingPosition] -= damage;
- }
- }
- }
- while (temp[1] != "Supernova");
- Console.WriteLine(String.Join("; ", planes));
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement