#include
void sort(int list[], int low, int high, int &k, int end)
{
int x = list[low];
while (low < high)
{
while (low < high)
{
if (list[high] >= x)
high--;
else
{
list[low] = list[high];
break;
}
}
while (low < high)
{
if (list[low] <= x)
low++;
else
{
list[high] = list[low];
break;
}
}
for (int i = 0; i <= end; i++)
{
printf("%d ", list[i]);
}
printf("\n");
}
list[low] = x;
k = low;
}
void quickSort(int list[], int low, int high, int end)
{
int k;
if (low < high)
{
sort(list, low, high, k, end);
quickSort(list, low, k - 1, end);
quickSort(list, k + 1, high, end);
}
}
int main(void)
{
int list[99] = {0};
int i;
printf("输入数字,以 -999 结束:\n");
for (i = 0; i < 99; i++)
{
scanf("%d", &list[i]);
if (list[i] == -999)
break;
}
int low = 0, high = i - 1;
int end = i - 1;
quickSort(list, low, high, end);
}