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

## Задача 01. The Hunting Games

Здравейте! Judge ми дава 80/100... Ако може някой да ми помогне :)

Благодаря предварително!

Линк към judge --> https://judge.softuni.bg/Contests/Practice/Index/1555#0

Решението ми -->

using System;

namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{

double totalWater = days * people* water;
double totalFood = days * people* food;

for (int i = 1; i <= days; i++)
{
energy -= energyLoss;

if (i % 2 == 0)
{
energy += (energy * 0.05);
totalWater -= (totalWater * 0.3);
}
if (i % 3 == 0)
{
totalFood -= (totalFood / people);
energy += (energy * 0.1);
}

if (energy <= 0)
{
Console.WriteLine(\$"You will run out of energy. You will be left with {totalFood:f2} food and {totalWater:f2} water.");
return;
}

}

Console.WriteLine(\$"You are ready for the quest. You will be left with - {energy:f2} energy!");
}
}
}

Тагове:
0
rlukarski 1 Точки

Сложи проверката за 0 енергия първа.

if (energy <= 0)
{
Console.WriteLine(\$"You will run out of energy. You will be left with {totalFood:f2} food and {totalWater:f2} water.");
return;
}

0
15/03/2019 20:11:09
Desislava011 0 Точки

Благодаря! :-)

0