标签:lazy target get tar blank mic clu bsp turn
#include <iostream> using namespace std; const int N = 1e5 + 10; int a[N]; void qsort(int l, int r) { if(l >= r) return; //边界边界,莫要忘了 int i = l - 1, j = r + 1, mid = a[l + r >> 1]; //这里mid不能是 l + r >> 1,然后a[i] < a[mid], a[j] > a[mid],这个样子就错了 while(i < j) { do i ++; while(a[i] < mid); do j --; while(a[j] > mid); if(i < j) swap(a[i], a[j]); } qsort(l, j); qsort(j + 1, r); } int main() { int n; cin >> n; for(int i = 0; i < n; i ++) cin >> a[i]; qsort(0, n - 1); for(int i = 0; i < n; i ++) cout << a[i] << ‘ ‘; }
标签:lazy target get tar blank mic clu bsp turn
原文地址:https://www.cnblogs.com/longxue1991/p/13074328.html