//www.galeon.com/crispolin
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#define tama 10

void Ordenamiento_Quicksort(int *arreglo,int izq, int der)
{
 int i,j,x,y;
 i=izq;     j=der;
 x=arreglo[(izq+der)/2];
 do{
 while(arreglo[i]<x&&j<der)i++;
 while(x<arreglo[j]&&j>izq)j--;
     if(i<=j)
       {
	y=arreglo[i];
	arreglo[i]=arreglo[j];
	arreglo[j]=y;
	i++;  j--;
       }//fin if
   }while(i<=j);
   if(izq<j)    Ordenamiento_Quicksort(arreglo,izq,j);
   if(i<der)    Ordenamiento_Quicksort(arreglo,i,der);

 }
void rapido(int *vector)
{
 Ordenamiento_Quicksort(vector,0,tama-1);
}

int main()
{
 int i, enteros[tama];
 clrscr();
 cout<<"ORDENAMIENTO POR QUICKSORT"<<endl<<endl;
 cout<<"dame el numero"<<endl;
 for(int i=0;i<tama;i++)
     {
      cout<<"entero["<<i<<"]= ";
      cin>>enteros[i];
     }
cout<<"ARREGLO ORIGINAL"<<endl;
for(i=0;i<tama;i++)
     {
      cout<<enteros[i]<<setw(5);
     }
 rapido(enteros);
 cout<<endl<<"ARREGLO ASCENDENTE"<<endl;
 for(i=0;i<tama;i++)
     {
      cout<<enteros[i]<<setw(5);
     }
 getch();
 delete enteros;
 return 0;
}
