Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ShootForTheWin
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- int[] shootTarget = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int countTarget = 0;
- string command = string.Empty;
- while ((command = Console.ReadLine()) != "End")
- {
- int index = int.Parse(command);
- if (index >= 0 && index <= shootTarget.Length - 1)
- {
- if (shootTarget[index] != -1)
- {
- int currentTarget = shootTarget[index];
- shootTarget[index] = -1;
- countTarget++;
- for (int i = 0; i <= shootTarget.Length - 1; i++)
- {
- if (shootTarget[i] <= currentTarget && shootTarget[i] != -1)
- {
- shootTarget[i] = shootTarget[i] + currentTarget;
- }
- else if (shootTarget[i] > currentTarget && shootTarget[i] != -1)
- {
- shootTarget[i] = shootTarget[i] - currentTarget;
- }
- }
- }
- }
- }
- Console.Write($"Shot targets: {countTarget} -> ");
- Console.WriteLine(string.Join(" ", shootTarget));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement