Advertisement
Guest User

Untitled

a guest
Oct 31st, 2020
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Counter_Strike
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int initial = int.Parse(Console.ReadLine());
  10. int distance = 0;
  11. int wins = 0;
  12. string command = string.Empty;
  13. while(initial > 0)
  14. {
  15. command = Console.ReadLine();
  16. if(command=="End of battle")
  17. {
  18. break;
  19. }
  20. else
  21. {
  22. distance = int.Parse(command);
  23. initial -= distance;
  24. wins++;
  25. if(wins%3==0)
  26. {
  27. initial += wins;
  28. }
  29. if(distance>initial || initial==0)
  30. {
  31. Console.WriteLine($"Not enough energy! Game ends with {wins} won battles and {initial} energy");
  32. }
  33. }
  34. }
  35. if (initial > 0)
  36. {
  37. Console.WriteLine($"Won battles: {wins}. Energy left: {initial}");
  38. }
  39. }
  40. }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement