hallo everybody, in fact, i wrote those codes but i encountered a difficulty in how to delete the duplication for example, i intered 3 4 6 6 7 3 the output comes like that
3 3 4 6 6 7. The questions is what are the codes that i have to add to make it like that
3 4 6 7 and where should i add them.thanks in advance
Code:
#include <stdio.h>
#include <conio.h>
#define max6
void quicksort (int a[] , int low , int high);
int partition ( int a[] , int low , int high);
void main()
{
int arr[max], i;
clrscr();
printf("enter the elements for array \n");
for(i= 0 ; i< max; i++)
scanf("%d", &arr[i]);
quicksort(arr , 0 , max-1);
printf("\n the sorted array is \n");
for( i= 0 ; i< max ; i++)
printf("%d" , arr[i]);
}
void quicksort ( int a[] , int low , int high)
{
int pivot;
if(low < high)
{
pivot = partition ( a , low , high);
quicksort ( a ,low , pivot - 1);
quicksort (a , pivot + 1 , high);
}
}
int partition ( int a[] , int low , int high)
{
int i , j , x , temp;
x = a[high];
i = low - 1;
for ( j = low ; j < high; j++)
{
if ( a [j] <= x)
{
i = i+1;
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
temp = a [i+1];
a[i+1] = a[high];
a[high] = temp;
return (i+1);
}