#include <stdio.h>
int findPivotPos(int *array,int arrStart,int arrEnd){
return arrStart;
}
int partition(int *array,int arrStart,int arrEnd,int pivotPos){
int pivotValue = array[pivotPos];
array [pivotPos]= array[arrEnd-1];
int ltPivotValueCount=0;
for (int i =arrStart;i<arrEnd-1;++i){
if(array[i]<pivotValue){
int temp =array[arrStart+ltPivotValueCount];
array[arrStart+ltPivotValueCount] =array[i];
array[i]=temp;
++ltPivotValueCount;
}
}
array[arrEnd-1]=array[arrStart+ltPivotValueCount];
array[arrStart+ltPivotValueCount]=pivotValue;
return arrStart+ltPivotValueCount;
}
void quickSort(int *array, int arrStart, int arrEnd){
if(arrEnd - arrStart < 2)
return;
int pivotPos = findPivotPos(array, arrStart, arrEnd);
int pivotOrderPos = partition(array, arrStart, arrEnd, pivotPos);
quickSort(array, arrStart, pivotOrderPos);
quickSort(array, pivotOrderPos + 1, arrEnd);
}
void printArray(int *arr, int arrLen)
{
for (int i = 0; i < arrLen; i++)
{
printf("%d ", arr[i]);
}
printf("\n");
}
int main () {
int a[11]={25,1,12,28,3,17,80};
quickSort(a, 0, 7);
printArray(a, 7);
return 0;
}