Stan0033

Untitled

Jun 11th, 2021
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. using System;
  2.  
  3. namespace strong_number
  4. {
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. int energy = int.Parse(Console.ReadLine());
  10.  
  11. int Cur_distance;
  12. int won_battles = 0;
  13. bool Not_Enough = false;
  14. // every 1/3 won battle increases your energy with the number or won battles
  15. while (true)
  16. {
  17. string command = Console.ReadLine();
  18. if (command == "End of battle") { break; }
  19. else
  20. {
  21.  
  22. Cur_distance = Convert.ToInt32(command);
  23.  
  24. if (energy >= Cur_distance)
  25. {
  26. energy -= Cur_distance; won_battles++;
  27.  
  28. if (won_battles % 3 == 0) { energy += won_battles; }
  29.  
  30. }
  31. else { Not_Enough = true;break; }
  32.  
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39. }
  40.  
  41.  
  42. if (Not_Enough)
  43. {
  44. Console.WriteLine($"Not enough energy! Game ends with {won_battles} won battles and {energy} energy");
  45. }
  46. else
  47. {
  48. Console.WriteLine($"Won battles: {won_battles}. Energy left: {energy}");
  49. }
  50. }
  51.  
  52. }
  53. }
  54.  
  55.  
Advertisement
Add Comment
Please, Sign In to add comment