int partition( int a[], int low, int high ) { int piwot, right, left; left = low+1 ; right = high ; piwot = a[low]; while(1) { while(a[right] > piwot) right--; while(a[left] < piwot && left < high) left++; if( left < right) swap(a, left, right); else{ swap(a, low, right); return right; } } } void quickSort(int a[], int low, int high) { int part; if(low < high) { part = partition(a, low, high); quickSort(a, low, part-1); quickSort(a, part+1, high); } }
a[right]
a[left]
piwot
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)