Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class Icarus
- {
- static void Main(string[] args)
- {
- const string endCommand = "Supernova";
- int codedDirection = 0;
- int[] plane = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int currPoss = int.Parse(Console.ReadLine());
- int currDamm = 1;
- string[] commandArgs = Console.ReadLine().Split();
- while (commandArgs[0] != endCommand)
- {
- string direction = commandArgs[0];
- int steps = int.Parse(commandArgs[1]);
- if (direction == "left") codedDirection = -1;
- else codedDirection = 1;
- for (int i = 0; i < steps; i++)
- {
- currPoss += codedDirection;
- if (currPoss < 0)
- {
- currPoss = plane.Length - 1;
- currDamm++;
- }
- else if (currPoss > plane.Length - 1)
- {
- currPoss = 0;
- currDamm++;
- }
- plane[currPoss] -= currDamm;
- }
- commandArgs = Console.ReadLine().Split();
- }
- Console.WriteLine(String.Join(' ', plane));
- }
- }
Add Comment
Please, Sign In to add comment