From 3f4af66f2b19db6b73d52f31ef594e0a3c837e6d Mon Sep 17 00:00:00 2001 From: Alexchent <1023615292@qq.com> Date: Sun, 4 Jul 2021 23:03:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=92=E6=B3=A1=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codehero/perg_match.php | 1 + suanfa/Base/bubble_sort.php | 1 + suanfa/Base/quick_sort.php | 1 + 3 files changed, 3 insertions(+) create mode 100644 codehero/perg_match.php create mode 100644 suanfa/Base/bubble_sort.php create mode 100644 suanfa/Base/quick_sort.php diff --git a/codehero/perg_match.php b/codehero/perg_match.php new file mode 100644 index 0000000..99086df --- /dev/null +++ b/codehero/perg_match.php @@ -0,0 +1 @@ + $arr[$j+1]) { $tmp = $arr[$j]; $arr[$j] = $arr[$j+1]; $arr[$j+1] = $tmp; } } } return $arr; } $sort = bubble_sort([2,6,19,4,5,8,3]); var_dump($sort); \ No newline at end of file diff --git a/suanfa/Base/quick_sort.php b/suanfa/Base/quick_sort.php new file mode 100644 index 0000000..2128d1e --- /dev/null +++ b/suanfa/Base/quick_sort.php @@ -0,0 +1 @@ += $base) { $right[] = $value; } else { $left[] = $value; } } if (count($left)) $left = quick_sort($left); if (count($right)) $right = quick_sort($right); return array_merge($left, [$base], $right); } $sort = quick_sort([2,6,19,4,5,8,3]); var_dump($sort); \ No newline at end of file