Advertisement
spasnikolov131

Untitled

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