Advertisement
petarkobakov

Counter Strike

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