void fun(int Array[], int L, int R)
{
if (L >= R)
return;
int temp = Array[L];
int tempL = L;
int tempR = R;
while (tempL < tempR)
{
while (tempL < tempR&&temp < Array[tempR])
{
tempR--;
}
int tempdata = Array[tempR];
Array[tempR] = Array[tempL];
Array[tempL] = tempdata;
while (tempL < tempR&&temp >= Array[tempL])
{
tempL++;
}
tempdata = Array[tempR];
Array[tempR] = Array[tempL];
Array[tempL] = tempdata;
}
fun(Array, L, tempL - 1);
fun(Array, tempL + 1, R);
}
快速排序
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.