Home Article Practice 快速排序,模板

快速排序,模板

2022-05-08 21:07  views:325  source:Coat    

void qs(int h[], int l, int r)
{
if (l >= r) return;
int x = h[l+r>>1], i = l - 1, j = r + 1;
while (i < j)
{
do i++; while (h[i] < x);
do j--; while (h[j] > x);
if (i < j) swap(h[i],h[j]);
}
if(l<j)
qs(h, l, j);
if (r > j);
qs(h, j+1, r);
}



Disclaimer: The above articles are added by users themselves and are only for typing and communication purposes. They do not represent the views of this website, and this website does not assume any legal responsibility. This statement is hereby made! If there is any infringement of your rights, please contact us promptly to delete it.

字符:    改为:
去打字就可以设置个性皮肤啦!(O ^ ~ ^ O)