p2p.wrox.com Forums (http://p2p.wrox.com/)
-   Visual C++ (http://p2p.wrox.com/visual-c-88/)
-   -   Quick Sort in C Code (http://p2p.wrox.com/visual-c/66347-quick-sort-c-code.html)

 yulin11 March 3rd, 2008 03:49 AM

Quick Sort in C Code

Reference:http://www.codeuu.com/Quicksort
Code:

```void quickSort(int numbers[], int array_size) {   q_sort(numbers, 0, array_size - 1); }     void q_sort(int numbers[], int left, int right) {   int pivot, l_hold, r_hold;     l_hold = left;   r_hold = right;   pivot = numbers[left];   while (left < right)   {     while ((numbers[right] >= pivot) && (left < right))       right--;     if (left != right)     {       numbers[left] = numbers[right];       left++;     }     while ((numbers[left] <= pivot) && (left < right))       left++;     if (left != right)     {       numbers[right] = numbers[left];       right--;     }   }   numbers[left] = pivot;   pivot = left;   left = l_hold;   right = r_hold;   if (left < pivot)     q_sort(numbers, left, pivot-1);   if (right > pivot)     q_sort(numbers, pivot+1, right); }```
everyone can go far!www.codeuu.com

 mindcoder March 11th, 2013 11:51 PM

that works cool

thanks, your algo works beautifully, i have been through few other codes they were all taking function arguments not liked by me

Good work [:)]

 RobertGreene June 13th, 2018 06:27 AM

C Coding

Great Job , Actually I am seeking for the exact C code that you have been mentioned in this forum post,although it works great keep updating more thanks

 All times are GMT -4. The time now is 01:42 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.