0
$sql     = "select pid from Athletes order by RAND()";
$results = mysql_query($sql) or die(mysql_error());
$total   = mysql_num_rows($results);

我需要在不同的总数中平均分配结果。每组最多 6 人,最少 4 人。我想做的是超过 2 组运动员。团队需要尽可能平均分配。

例子:

Total = 7 will have 2 groups with one having 4 and the other with 3.
Total = 17 will have 2 groups of 6 and one of 5.
Total = 25 will be 5 groups of 5.
Total = 26 will have 1 group of 6 and 4 groups of 5.

任何帮助将不胜感激。

谢谢!

4

0 回答 0