Similar questions have been asked before, but not answered the way I can work with it.
I have groups of 3, 4, 5 and 6 and each group is supposed to be filled with 50% boys and 50% girls. The user determines the amount of each group as well as the number of boys and girls.
For instance: 12 girls, 15 boys, 1*3, 2*4, 2*5 and 1*6 groups.
I already got the Random. How I can now put the randomly chosen boys/girls equally into the groups?
Random for boys and group of 4:
for (int i = 0; i < tischgruppenVierer; i++) //for each group of 4
{
for (int j = 0; j < 4/2; j++) //only do this two times because 50% boys
{
var picked = namesBoys[random.Next(0, namesBoys.Count())];
namesBoys.Remove(picked); //no duplicates
picked = new TischVier().student;
}
}
and the class TischVier
:
public class TischVier
{
public string student;
}
I hope this is enough code for you because I hardcoded it for every group.
I appreciate every thought because I am close to despair.
Aucun commentaire:
Enregistrer un commentaire