Advertisement
Spocoman

01. Counter-Strike

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