随机数
include[HTML_REMOVED]
using namespace std;
const int N=1000010;
void a(int p[],int l,int r){
if (l>=r) return;
int m= rand() % (r-l+1) + l;
int x=p[m],i=l-1,j=r+1;
while (i[HTML_REMOVED]x);
if (i<j) swap(p[i],p[j]);
}
a (p,l,j);
a (p,j+1,r);
}
int main(){
int n;
scanf(“%d”,&n);
int p[N];
for (int i=0;i<n;i) scanf(“%d”,&p[i]);
a (p,0,n-1);
for (int i=0;i<n;i) printf(“%d “,p[i]);
return 0;
}