Mim1111

Untitled

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