首页 > 试题广场 >

下面程序段的功能是实现一趟快速排序,请在下划线处填上正确的语

[填空题]

下面程序段的功能是实现一趟快速排序,请在下划线处填上正确的语句。

struct record {int key;datatype others;};

void quickpass(struct record r[], int s, int t, int &i)

{

int j=t; struct record x=r[s]; i=s;

while(i<j)

{

while (i<j && r[j].key>x.key) j=j-1;  if (i<j) {r[i]=r[j];i=i+1;}

while (__________1__________) i=i+1;  if (i<j) {r[j]=r[i];j=j-1;}

}

____________2_____;

}

?
发表于 2020-10-10 10:18:05 回复(0)
1 i<j && r[i].key<x.key
2 r[i]=x

其中 i 是左指针,j是右指针;
x是pivot值。

发表于 2021-03-22 22:05:33 回复(0)
(1)i
发表于 2019-11-25 10:17:46 回复(0)