Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Numerics;
- using System.Threading;
- namespace exampreparation
- {
- class exam
- {
- static void Main(string[] args)
- {
- List<int> targets = Console.ReadLine().Split().Select(int.Parse).ToList();
- string[] command = Console.ReadLine().Split().ToArray();
- while (command[0] != "End")
- {
- if (command[0] == "Shoot")
- {
- int index = int.Parse(command[1]);
- if (index >= 0 && index < targets.Count)
- {
- int power = int.Parse(command[2]);
- targets[index] -= power;
- if (targets[index] <= 0)
- {
- targets.RemoveAt(index);
- }
- }
- }
- if (command[0] == "Add")
- {
- int index = int.Parse(command[1]);
- if (index >= 0 && index < targets.Count)
- {
- int value = int.Parse(command[2]);
- targets.Insert(index, value);
- }
- else
- {
- Console.WriteLine("Invalid placement!");
- }
- }
- if (command[0] == "Strike")
- {
- int index = int.Parse(command[1]);
- if (index >= 0 && index < targets.Count - 1)
- {
- int range = int.Parse(command[2]);
- if (index - range >= 0 && index + range < targets.Count)
- {
- targets.RemoveRange(index - range, range * 2 + 1);
- }
- else
- {
- Console.WriteLine("Strike missed!");
- }
- }
- }
- command = Console.ReadLine().Split().ToArray();
- }
- Console.WriteLine(string.Join("|", targets));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement