Advertisement
abushik

Problem_1._Counter_Strike

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