Advertisement
Guest User

Counter Strike 42/100

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