Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- namespace ConsoleApp1
- {
- class Exam
- {
- static void Main(string[] args)
- {
- int[] targets = Console.ReadLine().Split().Select(int.Parse).ToArray();
- string command = "";
- int counter = 0;
- while ((command = Console.ReadLine()) != "End")
- {
- int indexTarget = int.Parse(command);
- if (indexTarget > targets.Length - 1)
- {
- continue;
- }
- for (int i = 0; i < targets.Length; i++)
- {
- int temp = targets[indexTarget];
- if (targets[indexTarget] != -1)
- {
- targets[indexTarget] = -1;
- }
- if (temp == -1)
- {
- continue;
- }
- if (targets[i] > temp && targets[i] != -1)
- {
- targets[i] -= temp;
- }
- if (targets[i] <= temp && targets[i] != -1)
- {
- targets[i] += temp;
- }
- }
- }
- foreach (var item in targets)
- {
- if (item == -1)
- {
- counter++;
- }
- }
- Console.WriteLine($"Shot targets: {counter} ->" + " " + string.Join(' ', targets));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement