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 P02.Icarus
- {
- class Program
- {
- static void Main(string[] args)
- {
- var planes = Console.ReadLine()
- .Split(' ')
- .Select(int.Parse)
- .ToArray();
- int startPosition = int.Parse(Console.ReadLine());
- string[] command = Console.ReadLine()
- .Split(' ');
- int damage = 1;
- while (command[0] != "Supernova")
- {
- int steps = int.Parse(command[1]);
- if (command[0] == "right")
- {
- while (steps >= 1)
- {
- if (startPosition == planes.Length - 1)
- {
- startPosition = -1;
- damage++;
- }
- startPosition++;
- planes[startPosition] -= damage;
- steps--;
- }
- }
- else if (command[0] == "left")
- {
- while (steps >= 1)
- {
- if (startPosition == 0)
- {
- startPosition = planes.Length;
- damage++;
- }
- startPosition--;
- planes[startPosition] -= damage;
- steps--;
- }
- }
- command = Console.ReadLine().Split(' ');
- }
- Console.WriteLine(string.Join(" ", planes));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment