P1177 【模板】排序
1.快速排序
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long int
int a[100005];
void qsort(int l, int r) {int x = l, y = r;int mid = a[(x + y) / 2];while (x <= y) {while (a[x] < mid) x++;while (a[y] > mid) y--;if (x <= y) {swap(a[x], a[y]);x++;y--;}}if (x < r) qsort(x, r);if (y > l) qsort(l, y);}
signed main() {int n; cin >> n;for (int i = 1; i <= n; i++) {cin >> a[i];}qsort(1, n);for (int i = 1; i <= n; i++) {cout<< a[i]<<' ';}return 0;
}