Help me in the following situation: There are names, in the future there will be more. The program have to pick a random name, and a random number for it between 1 and 28 (1 and 28 should be included too). The program should write out that the "ID:rand.number winner is: rand.name" And repeat it until there is no number between 1 and 28(1 and 28 should be included too). Without duplication. If u can help me, please edit THIS code. :)
Thanks in advance!!!
static void Main(string[] args) { string[] Names = { "Erik", "Levente", "Noel", "Áron", "Krisztián", "Kristóf", "Bence", "Roland", "Máté", "László", "Bálint", "Regina", "Brigitta", "Gréta", "Hédi", "Hanna", "Boglárka", "Jázmin", "Réka", "Alexandra", "Rebeka", "Lili", "Luca", "Zsófi" };
Random r = new Random();
Names = Names.OrderBy(_ => r.Next()).ToArray();
for (int i = 0; i < Names.Length; i++)
{
Console.WriteLine("The ID : " + (i + 1) + " winner: " + Names[i]);
}
Console.ReadKey(true);
}
Aucun commentaire:
Enregistrer un commentaire