i'm trying to write a quicksort but my partition is not working properly can some help me please
void parttition(int myArray[],int first, int last);
void quicksort(int myArray[],int first, int last);
void quick( int size)
{
int myArray[10];
int x;
srand((unsigned)time(0));
for (x=0;x<size;x++)
{
int random_integer = rand()/25;
myArray[x]=random_integer;
printf("%d\n",myArray[x]);
}
printf("\n\n\n\n");
int first,last;
first=0;
last=size-1;
parttition( myArray,first, last);
//for (x=0;x<size;x++)
//{
// printf("%d\n",myArray[x]);
//}
}
void parttition(int myArray[],int first, int last)
{
int pivot,f,l;
pivot=myArray[last];
f=first;
l=last-1;int temp=0,temp1=0;
int x;bool state1=false,state2=false,state3=false;
while( f<l)
{
while((state1==false)&&(f<last))
{
if (myArray[f]>pivot)
{
f++;
}
else
{
state1=true;
}
}
while((state2==false)&&(l>first))
{
if (myArray[l]<pivot)
{
l--;
}
else
{
state2=true;
}
}
printf("\n%d\n",myArray[f]);
printf("%d\n",myArray[l]);
if (l<f)
{
temp=myArray[f];
myArray[f]=myArray[l];
myArray[l]=temp;
state3=true;
if ((myArray[f]>pivot)&&(state3==true))
{
temp1=myArray[f];
myArray[f]=myArray[last];
myArray[last]=temp1;
}
}
else
{
if ((myArray[l]>pivot)&&(state3==true))
{
temp1=myArray[l];
myArray[l]=myArray[last];
myArray[last]=temp1;
}
}
printf("\n%d\n",myArray[f]);
printf("%d\n",myArray[l]);
int x;
printf("\n");
for (x=0;x<3;x++)
{
printf("%d\n",myArray[x]);
}
parttition(myArray,first, l);
parttition(myArray,f, last);
}
}