function horseGoods($horse,$goods)
{
$array = [];
for ($a=0; $a <= ($horse/3); $a++) {
for ($b=0; $b < ($horse/2); $b++) {
$c = $horse - $a - $b ;
if (3*$a + 2*$b + $c/2 == $goods) {
$array[] = [
'a'=>$a,
'b'=>$b,
'c'=>$c,
];
}
}
}
return $array;
}
网友评论