quick sort using a c++ program

#include
#include
int n;
class quicksort
{
public:
int a[10];
void input();
void qsort(int,int);
void output();
void swap(int &,int &);
int median(int,int);
};
void quicksort::input()
{
int i;
cout<<"\t\tQuick Sort";
cout<<"\n\t\t~~~~~ ~~~~";
cout<<"\n\n Enter the size of array";
cin>>n;
cout<<"\n Enter the array elements:";
for(i=0;i cin>>a[i];
}
int quicksort::median(int left,int right)
{
int center=(left+right)/2;
if(a[center] swap(a[left ],a[center]);
if(a[right] swap(a[left],a[right]);
if(a[right] swap(a[center],a[right]);
swap(a[center],a[right-1]);
return(a[right-1]);
}
void quicksort::output()
{
cout<<"\n Sorted elements are";
for(int i=0;i cout<<" "< }
void quicksort::swap(int &a,int &b)
{
int t;
t=a;
a=b;
b=t;
}
void quicksort::qsort(int left,int right)
{
if(left {
int pivot=median(left,right);
int i=left,j=right-1;
for(;;)
{
while(a[++i] while(pivot if(i swap(a[i],a[j]);
else
break;
}
if(i swap(a[i],a[right-1]);
qsort(left,i-1);
qsort(i+1,right);
}
}
void main()
{
quicksort qs;
clrscr();
qs.input();
qs.qsort(0,n-1);
qs.output();
getch();
}

Comments