Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Numerics;
- namespace CounterStrike
- {
- class Program
- {
- static void Main()
- {
- int initialEnergy = int.Parse(Console.ReadLine());
- string command = Console.ReadLine();
- int counter = 0;
- while (command != "End of battle")
- {
- int distanceOfTheEnemy = int.Parse(command);
- initialEnergy -= distanceOfTheEnemy;
- counter++;
- if (initialEnergy <= 0)
- {
- initialEnergy = 0;
- Console.WriteLine($"Not enough energy! Game ends with {counter} won battles and {initialEnergy} energy");
- return;
- }
- if (counter % 3 == 0)
- {
- initialEnergy += 3;
- }
- command = Console.ReadLine();
- }
- Console.WriteLine($"Won battles: {counter}. Energy left: {initialEnergy} ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement