From 2502467ed4c271e1992540462d36ccde8fd7ad21 Mon Sep 17 00:00:00 2001 From: newde Date: Wed, 4 Feb 2026 18:23:49 -0500 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E5=82=B3=E6=AA=94=E6=A1=88=E5=88=B0?= =?UTF-8?q?=E3=80=8C260202=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 260202/快速排序.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 260202/快速排序.cpp diff --git a/260202/快速排序.cpp b/260202/快速排序.cpp new file mode 100644 index 0000000..63a984e --- /dev/null +++ b/260202/快速排序.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; + +int main(){ + int n; + int a[n]; + cin >> n; + for (int i=0;i> a[i]; +// ѡ򣺸 i λʵģСģ +for (int i = 0; i < n - 1; i++) { + int minidx = i; // 1. ȼµǰλ + for (int j = i + 1; j < n; j++) { + if (a[j] < a[minidx]) { // 2. ָС + minidx = j; // 3. ֻǼλã + } + } + swap(a[i], a[minidx]); // 4. ȫֻһ +} + for(int i=0;i