PHP-约瑟夫环

xiaoxiao2021-02-27  165

<?php function ysf($n,$m){ $arr=range(1, $n); $i=0; while($m<=count($arr)){ ++$i; $survice=array_shift($arr); if($i%$m<>0){ array_push($arr, $survice); }else{ $i=0; } } return $arr; } $res=ysf(7,3);

print_r($res);

------------------------------------------------------------------------

转载请注明原文地址: https://www.6miu.com/read-14671.html

最新回复(0)