Guest User

Untitled

a guest
Jun 13th, 2020
164
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5.  
  6. namespace ConsoleApp1
  7. {
  8. class Exam
  9. {
  10. static void Main(string[] args)
  11. {
  12. int[] targets = Console.ReadLine().Split().Select(int.Parse).ToArray();
  13.  
  14. string command = "";
  15.  
  16. int counter = 0;
  17.  
  18. while ((command = Console.ReadLine()) != "End")
  19. {
  20.  
  21. int indexTarget = int.Parse(command);
  22.  
  23. if (indexTarget > targets.Length - 1)
  24. {
  25. continue;
  26. }
  27.  
  28. for (int i = 0; i < targets.Length; i++)
  29. {
  30. int temp = targets[indexTarget];
  31.  
  32. if (targets[indexTarget] != -1)
  33. {
  34. targets[indexTarget] = -1;
  35. }
  36.  
  37. if (temp == -1)
  38. {
  39. continue;
  40. }
  41.  
  42. if (targets[i] > temp && targets[i] != -1)
  43. {
  44. targets[i] -= temp;
  45. }
  46. if (targets[i] <= temp && targets[i] != -1)
  47. {
  48. targets[i] += temp;
  49. }
  50.  
  51. }
  52.  
  53.  
  54. }
  55.  
  56. foreach (var item in targets)
  57. {
  58. if (item == -1)
  59. {
  60. counter++;
  61. }
  62. }
  63.  
  64. Console.WriteLine($"Shot targets: {counter} ->" + " " + string.Join(' ', targets));
  65.  
  66.  
  67. }
  68. }
  69. }
RAW Paste Data