Home Article Practice 归并排序,模板

归并排序,模板

2022-05-08 21:08  views:423  source:Coat    

void bg(int h[], int l, int r)
{
if (l >= r)return;
int mid = l + r >> 1;
bg(h, l, mid), bg(h, mid + 1, r);
int k = 0, i = l, j = mid + 1;
while (i <= mid && j <= r)
{
if (h[i] <= h[j]) te[k++] = h[i++];
else te[k++] = h[j++];
}
while (i <= mid) te[k++] = h[i++];
while (j <= r)te[k++] = h[j++];
for (i = l, j = 0; i <= r; i++, j++)
h[i] = te[j];
}



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)