Untitled

mail@pastecode.io avatar
unknown
csharp
18 days ago
1.3 kB
1
Indexable
Never
Console.OutputEncoding = System.Text.Encoding.UTF8;

string[] Names = new string[]
{
            "Name1",
            "Name2",
            "Name3",
            "Name4",
            "Name5",
            "Name6",
            "Name7",
            "Name8",
            "Name9",
            "Name10",
 };

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;
    }
}

// расчет количества команд
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");
}


string[][] teams = new string[teamsAmount][];

for (int i = 0; i < teams.Length; i++)
{
    for (int j = 0; j < 2; j++)
        teams[i] = new string[] { Names[i], Names[j] };
};

Console.WriteLine(teams);


/*
 
 */
Leave a Comment