您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP兑现各种排序

2025/5/23 0:35:11发布22次查看
php实现各种排序
5){ while($low $temp){ $high --; } $list[$low] = $list[$high]; while($low 0; $i --){ swap($list, $i, 0); heapfy($list, 0, $i - 1); }}//创建堆function buildheap(&$list){ for($i = (count($list) - 2)/2; $i >= 0; $i --){ heapfy($list, $i, count($list) - 1); }}//维护堆function heapfy(&$list, $low, $high){ $temp = $list[$low]; for($i = ($low * 2 + 1); $i = 1){ for($i = $code; $i = 0 && $list[$j] > $temp; $j -= $code){ $list[$j + $code] = $list[$j]; $a ++; } $list[$j + $code] = $temp; } } $code = $code/3; } echo $a;}//直接插入排序function insert(&$list){ $a = 0; for($i = 1; $i $temp; $j --){ $a ++; $list[$j + 1] = $list[$j]; } $list[$j + 1] = $temp; } } echo $a;}//简单选择排序function select(&$list){ $a = 0; for($i = 0; $i = $i; $j --){ $a ++; if($list[$j] > $list[$j + 1]){ $swap = true; swap($list, $j, $j + 1); } } } echo $a;}//移动或交换函数function swap(&$list, $i, $j){ $temp = $list[$i]; $list[$i] = $list[$j]; $list[$j] = $temp;}?>
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product