为啥前三个点WA,第一个点55350排在4048105和4695482之后输出,奇怪!
#include<iostream>
using namespace std;
int a[1000010];
void qsort(int a[], int l, int r){
int i = l, j = r, mid = a[(l + r) / 2];
do{
while(a[i] < mid) i++;
while(a[j] > mid) j--;
if(i <= j){
int t;
t = a[i];
a[i] = a[j];
a[j] = t;
}
i++; j--;
} while(i <= j);
if(i < r) qsort(a, i, r);
if(j > l) qsort(a, l, j);
}
int main(){
int n;
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
qsort(a, 1, n);
int f = 1;
for(int i = 1; i <= n; i++){
if(f) {cout << a[i]; f = 0;}
else cout << " " << a[i];
}
return 0;
}
谢谢