Advertisement
dinko_dt

Untitled

Apr 7th, 2020
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5.  
  6. namespace CounterStrike
  7. {
  8. class Program
  9. {
  10. static void Main()
  11. {
  12. int initialEnergy = int.Parse(Console.ReadLine());
  13. string command = Console.ReadLine();
  14. int counter = 0;
  15.  
  16. while (command != "End of battle")
  17. {
  18. int distanceOfTheEnemy = int.Parse(command);
  19. initialEnergy -= distanceOfTheEnemy;
  20.  
  21. counter++;
  22. if (initialEnergy <= 0)
  23. {
  24. initialEnergy = 0;
  25. Console.WriteLine($"Not enough energy! Game ends with {counter} won battles and {initialEnergy} energy");
  26. return;
  27. }
  28. if (counter % 3 == 0)
  29. {
  30. initialEnergy += counter;
  31. }
  32.  
  33. command = Console.ReadLine();
  34. }
  35. Console.WriteLine($"Won battles: {counter}. Energy left: {initialEnergy} ");
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement