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