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);


	}	


}

Just use use the built in C library QuickSort function.

qsort (myArray, 10, sizeof (int), compare)

int compare ( const void *arg1, const void *arg2 ) {
if ((int) *arg1 > (int) *arg2)
return 1;
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.