Merge pull request #305 from lvxianchao/patch-1

修正冒泡排序
This commit is contained in:
wangzheng0822 2019-05-09 08:46:16 +08:00 committed by GitHub
commit 4bce5028d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,7 @@ function bubbleSort(&$arr)
for ($i = 0; $i < $length; $i++) {
$flag = false;
for ($j = 0; $j < $length - $i - 1; $j++) {
if ($arr[$i] > $arr[$j + 1]) {
if ($arr[$j] > $arr[$j + 1]) {
$tmp = $arr[$j];
$arr[$j] = $arr[$j + 1];
$arr[$j + 1] = $tmp;