Home > Backend Development > PHP Tutorial > php 冒泡排序跟快速排序

php 冒泡排序跟快速排序

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:52:01
Original
742 people have browsed it

php 冒泡排序和快速排序

冒泡


$arr = Array(23,34,12,56,43,98,89);
for($i=0;$i
for($j=0;$j
if($arr[$j]>$arr[$j+1]){
$tmp = $arr[$j];
$arr[$j] = $arr[$j+1];
$arr[$j+1] = $tmp;
}
}
}
?>

?

快速


$arr = Array(23,34,12,56,43,98,89);
for($i=0;$i
for($j=0;$j
if($arr[$j]>$arr[$j+1]){
$tmp = $arr[$j];
$arr[$j] = $arr[$j+1];
$arr[$j+1] = $tmp;
}
}
}
?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template