El siguiente programa esta orientado a objetos
import java.util.Scanner;
public class MetodoQuickSort {
public static void main(String[] args) {
QuickSort quick = new QuickSort();
double ar[];
ar = new double[10];
Scanner ent = new Scanner(System.in);
for(int i =0; i<10; i++)
{
System.out.println("Intoduce el valor: " + (i + 1) );
ar[i] = ent.nextInt();
}
quick.Ordenamiento(ar, 0, ar.length-1);
quick.ImprimirDatos();
}
}
import java.util.Scanner;
public class MetodoQuickSort {
public static void main(String[] args) {
QuickSort quick = new QuickSort();
double ar[];
ar = new double[10];
Scanner ent = new Scanner(System.in);
for(int i =0; i<10; i++)
{
System.out.println("Intoduce el valor: " + (i + 1) );
ar[i] = ent.nextInt();
}
quick.Ordenamiento(ar, 0, ar.length-1);
quick.ImprimirDatos();
}
}
import java.util.*;
public class QuickSort {
public double ar[];
public int i;
public int j;
public int central;
public double pivote;
public int ultimo;
public double temp;
public int arr[];
Scanner ent = new Scanner(System.in);
//Metodo para introducri datos
public void Ordenamiento(double a[], int primero, int ultimo)
{
this.ar = a;
central =(primero + ultimo)/2;
pivote = a[central];
i = primero;
j = ultimo;
do{
while(a[i]<pivote)i++;
while(a[j] > pivote)j--;
if(i <= j)
{
temp =a[j];
a[j] = a[i];
a[i] = temp;
i++;
j--;
}
}while(i<=j);
if(primero <j)
Ordenamiento(a, primero, j);
if(i < ultimo)
Ordenamiento(a, i, ultimo);
}
public void ImprimirDatos()
{
for(int i = 0; i<10; i++)
{
System.out.println("Valor ordenado: " + ar[i]);
}
}
}