Advertisement
silvana1303

shoot for the win

Jun 28th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Numerics;
  5. using System.Threading;
  6.  
  7. namespace exampreparation
  8. {
  9.     class exam
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<int> targets = Console.ReadLine().Split().Select(int.Parse).ToList();
  14.  
  15.             string command = Console.ReadLine();
  16.  
  17.             int count = 0;
  18.  
  19.             while (command != "End")
  20.             {
  21.                 int hit = int.Parse(command);
  22.  
  23.                 if (hit >= 0 && hit < targets.Count)
  24.                 {
  25.                     if (targets[hit] != -1)
  26.                     {
  27.                         int temp = targets[hit];
  28.                         targets[hit] = -1;
  29.                         count++;
  30.  
  31.                         for (int i = 0; i < targets.Count; i++)
  32.                         {
  33.                             if (targets[i] != -1)
  34.                             {
  35.                                 if (targets[i] > temp)
  36.                                 {
  37.                                     targets[i] -= temp;
  38.                                 }
  39.                                 else
  40.                                 {
  41.                                     targets[i] += temp;
  42.                                 }
  43.                             }
  44.                         }
  45.                     }
  46.                 }
  47.  
  48.                 command = Console.ReadLine();
  49.             }
  50.  
  51.             Console.WriteLine($"Shot targets: {count} -> {string.Join(" ", targets)}");
  52.         }
  53.  
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement