/*Program for splitting an array*/


#include 
#include 

void main()
{
void split(int [],int);
int array[10],i,pivot;
clrscr();
printf("nnnttt Program for spliting an array");
printf("nnnttt Enter 8 elements of an array");
for(i=0;i<8;i++)
{
printf("nntttt Array[%d]=",i);
scanf("%d",&array[i]);
}
printf("nnnttt Enter pivot value = ");
scanf("%d",&pivot);
split(array,pivot);
getch();
}

void split(int arr[],int pivot)
{
int p,q,t,i,flag=1;
p=0;
q=7;
while(p<q) {="" while(arr[p]<="pivot)" p++;="" while(arr[q]="">pivot)
q--;

if(arr[p]>arr[q] && p<q) {="" t="arr[p];" arr[p]="arr[q];" arr[q]="t;" }="" printf("nnttt");="" for(i="0;i<8;i++)" if(arr[i]="">pivot && flag==1)
{
printf(" <--Spliting pointnnttt");
flag=0;
}
printf("%dnnttt",arr[i]);
}
}

Leave a Reply

Leave a Reply

Your email address will not be published.