Untitled
unknown
csharp
2 years ago
2.7 kB
8
Indexable
string[] Names = new string[]
{
"Name1",
"Name2",
"Name3",
"Name4",
"Name5",
"Name6",
"Name7",
"Name8",
"Name9",
"Name10",
"Name11",
};
// расчет количества команд
int teamsAmount = CalculateTeamsAmount();
Console.WriteLine("Добро пожаловать в Рандомайзер!");
Console.WriteLine("0. Список участников");
Console.WriteLine("============================");
Console.WriteLine("Выберите способ генерации: ");
Console.WriteLine("1. По порядку");
Console.WriteLine("2. По случайности");
Console.Write("Выбор: ");
int inputPoint = Convert.ToInt32(Console.ReadLine());
switch (inputPoint)
{
case 0:
// TODO: Вывести список участников
break;
case 1:
GenerateTeamsByOrder(teamsAmount);
break;
case 2:
GenerateTeamsByRandom(teamsAmount);
break;
default:
break;
}
void GenerateTeamsByOrder(int teamsAmount)
{
string[][] teams = new string[teamsAmount][];
int j = 0;
for (int i = 0; i < teams.Length; i++, j += 2)
{
if ((j + 1) < Names.Length) // 11 < 10
{
teams[i] = new string[] { Names[j], Names[j + 1] };
}
else
{
teams[i] = new string[] { Names[j] };
}
};
for (int i = 0; i < teams.Length; i++)
{
foreach (var player in teams[i])
{
Console.WriteLine($"Команда {i}: {player}");
}
Console.WriteLine();
}
}
void GenerateTeamsByRandom(int teamAmount)
{
// TODO: Just do it!
}
int CalculateTeamsAmount()
{
int teamsAmount = 0;
if (Names.Length > 0)
{
teamsAmount = Names.Length / 2;
if (Names.Length % 2 > 0)
{
teamsAmount += 1;
Console.WriteLine("количество команд: " + teamsAmount);
}
else
{
Console.WriteLine("количество команд: " + teamsAmount);
}
}
else
{
Console.WriteLine("No players");
}
return teamsAmount;
}
void GetRandomNames()
{
Random random = new Random();
string first = Names[random.Next(Names.Length)];
Console.WriteLine(first);
while (true)
{
string second = Names[random.Next(Names.Length)];
if (first != second)
{
Console.WriteLine(second);
break;
}
else
{
continue;
}
}
}Editor is loading...
Leave a Comment