public static void randomizator() { potas.Clear(); foreach (Santa a in dalyviai) { potas.Add(a); } Random rnd = new Random(); foreach (Santa participant in dalyviai) { bool stop = false; Santa istrauktas = null; int number = -1; number = rnd.Next(0, potas.Count); istrauktas = (Santa)potas[number]; if (participant == istrauktas) { stop = true; randomizator(); } if (stop) { return; } participant.asignee = istrauktas; potas.RemoveAt(number); } }
public static void randomizator() { foreach (Santa a in dalyviai) { potas.Add(a); } Random rnd = new Random(); foreach (Santa participant in dalyviai) { bool stop = false; Santa istrauktas = null; int number = -1; number = rnd.Next(0, potas.Count); istrauktas = (Santa)potas[number]; Console.WriteLine(participant.name + " " + istrauktas.name); if (participant == istrauktas) { stop = true; randomizator(); } if (stop) { return; } participant.asignee = istrauktas; potas.RemoveAt(number); } //vienas.sendMail("*****@*****.**"); Console.Read(); }
private void button1_Click(object sender, System.EventArgs e) { Santa naujas = new Santa(nameBox.Text, mailBox.Text); listBox.Items.Add(naujas.name); dalyviai.Add(naujas); potas.Add(naujas); }