$new=array(9,2,8,4,2,5); for($i = 0;$i<count($new);$i++){ for($j = 0;$j<count($new)-1;$j++){ if($new[$j]>$new[$j+1]){ $temp = $new[$j]; $new[$j] = $new[$j+1]; $new[$j+1]=$temp; } } } print_r($new);
冒泡排序
最新推荐文章于 2023-06-06 09:14:05 发布
$new=array(9,2,8,4,2,5); for($i = 0;$i<count($new);$i++){ for($j = 0;$j<count($new)-1;$j++){ if($new[$j]>$new[$j+1]){ $temp = $new[$j]; $new[$j] = $new[$j+1]; $new[$j+1]=$temp; } } } print_r($new);