Advertisement
silvana1303

counter strike

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