void quicksort_array(int b[], int low, int high)
{
if (low < high)
{
int n = quicksort_array_partition(b, low, high);
quicksort_array(b, low, n - 1);
quicksort_array(b, n + 1, high);
}
else
{
return;
}
}
int quicksort_array_partition(int b[], int low, int high)
{
int temp;
int left = low;
int right = high;
int pivot = b[low];
while (1)
{
while (b[left] <= pivot && left < high)
left++;
while (b[right] > pivot)
right--;
if (left >= right)
break;
temp = b[right];
b[right] = b[left];
b[left] = temp;
}
temp = b[right];
b[right] = b[low];
b[low] = temp;
return right;
}
이게 어레이인데 이건 원하는대로 출력되여
이걸 포인터로 바꿔서 출력하려고 하는데
void quicksort_pointer(int *low, int *high)
{
if (*low < *high)
{
int* n = quicksort_pointer_partition(low, high);
quicksort_pointer(low, n-1);
quicksort_pointer(n+1, high);
}
else
{
return;
}
}
int *quicksort_pointer_partition(int *low, int *high)
{
int temp;
int* left = low;
int* right = high;
int pivot = *low;
while (1)
{
while (left <= pivot && left>high)
left++;
while (right > pivot)
right--;
if (left<right)
break;
temp = right;
right = left;
left = temp;
}
temp = right;
right = low;
low = temp;
return right;
}
이렇게 하면 다르게 출력되요... ㅠㅠ 도와주세요 행님덜
댓글 0