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

## 04. Trekking Mania - Programming Basics Online Exam - 28 and 29 March 2020

using System;

namespace _04.TrekkingMania
{
class StartUp
{
static void Main(string[] args)
{

int g1 = 0;
int g2 = 0;
int g3 = 0;
int g4 = 0;
int g5 = 0;

for (int i = 1; i <= n; i++)
{

if (climbersCount < 6)
{
g1 += climbersCount;
}

else if (climbersCount < 13)
{
g2 += climbersCount;
}

else if (climbersCount < 26)
{
g3 = climbersCount;
}

else if (climbersCount < 41)
{
g4 += climbersCount;
}

else
{
g5 += climbersCount;
}
}

int totalCount = g1 + g2 + g3 + g4 + g5;

Console.WriteLine(\$"{1.0 * g1 / totalCount * 100:f2}%");
Console.WriteLine(\$"{1.0 * g2 / totalCount * 100:f2}%");
Console.WriteLine(\$"{1.0 * g3 / totalCount * 100:f2}%");
Console.WriteLine(\$"{1.0 * g4 / totalCount * 100:f2}%");
Console.WriteLine(\$"{1.0 * g5 / totalCount * 100:f2}%");
}
}
}

81/100

Къде греша?

Тагове:
0
MartinBG 3587 Точки

Грешката е тук:

``````                else if (climbersCount < 26)
{
g3 = climbersCount;
}``````

Трябва да е:

``````                else if (climbersCount < 26)
{
g3 += climbersCount;
}``````

1