+ Нов въпрос
zakaza 0 Точки

## Counter Strike ?!? Mid Exam Retake 7 April 2020 C#

Здравейте, може ли някой да ми даде насоки за задачата и да ми каже къде бъркам?

Моето решение - https://pastebin.com/MVRLnxC3 C#

Тагове:
0
Axiomatik 100 Точки

Two problems:

Line 20 : In output-message use remaining energy and not 0 for the final message.

Line 27-30 : Energy needs to be increased with the current round-counter, which is 3 at the first time, 6 the second time …

Best,

Refactored code (100%) :

using System;

namespace Counter_Strike
{
class Program
{
static void Main(string[] args)
{
string input = string.Empty;

int rountCounter = 0;

while ((input = Console.ReadLine()) != "End of battle")
{
int distance = int.Parse(input);

if (energy < distance)
{
Console.WriteLine(\$"Not enough energy! Game ends with {rountCounter} won battles and {energy} energy");
return;
}

rountCounter++;
energy -= distance;

if (rountCounter % 3 == 0)
{
energy += rountCounter;
}
}

Console.WriteLine(\$"Won battles: {rountCounter}. Energy left: {energy}");
}
}
}

0
zakaza 0 Точки

Thank you!

0