Advertisement
marto9119

MartoooE

May 25th, 2023
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | Source Code | 0 0
  1. using System;
  2.  
  3. namespace _01._Counter_Strike
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int playrEnergy = int.Parse(Console.ReadLine());
  10.             int countWon = 0;
  11.             string batleComands = Console.ReadLine();
  12.  
  13.             while (batleComands != "End of battle")
  14.             {
  15.                 int needEnergy = int.Parse(batleComands);
  16.                 if (countWon % 3 == 0 && playrEnergy + countWon >= needEnergy)
  17.                 {
  18.                     playrEnergy += countWon;
  19.                 }
  20.  
  21.                 if (playrEnergy >= needEnergy)
  22.                 {
  23.                     playrEnergy -= needEnergy;
  24.                     countWon++;
  25.                 }
  26.                 else
  27.                 {
  28.                     Console.WriteLine($"Not enough energy! Game ends with {countWon} won battles and {playrEnergy} energy");
  29.                     break;
  30.                 }
  31.  
  32.                 batleComands = Console.ReadLine();
  33.             }
  34.  
  35.             if (batleComands == "End of battle")
  36.             {
  37.                 Console.WriteLine($"Won battles: {countWon}. Energy left: {playrEnergy}");
  38.             }
  39.  
  40.         }
  41.     }
  42. }
Tags: softuni
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement