Netbeans - Quicksort

 
Vista:
Imágen de perfil de Andrea

Quicksort

Publicado por Andrea (2 intervenciones) el 25/04/2016 22:19:48
Hola amigos ando con problemas con quicksort, tengo que hacer una clase empleado con id, nombre, y sueldo. en la principal ingresar datos el usario eso ya lo hice pero con el metodo quicksort tengo que ordenarlos por medio de la id asendentey no se como hacerlo, alguien me puede ayudar, se lo agradeceria mucho, es en java netbeans .


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
clase principal
 
package quicksort;
 
import java.io.*;
 
 
 
 
 
public class Quicksort {
 
public static BufferedReader entrada= new BufferedReader(new InputStreamReader(System.in));
 
 
 
    public static void main(String[] args) throws IOException {
 
        // TODO code application logic here
 
 
 
        empleado a[]=new empleado[1];
 
 
 
        String nombre;
 
        int sueldo;
 
        int id;
 
 
 
        for(int i=0;i<a.length;i++){
 
            System.out.println("Ingrese nombre");
 
            nombre=entrada.readLine();
 
            System.out.println("Ingese id");
 
            id=Integer.parseInt(entrada.readLine());
 
            System.out.println("ingrse el sueldo");
 
            sueldo=Integer.parseInt(entrada.readLine());
 
 
 
            a[i]=new empleado(nombre, id,sueldo);
 
        }
 
        System.out.println("Id"+ "  |  "  + "Nombre" + "  |  "+"Sueldo");
 
	for(int i=0;i<a.length;i++){
 
 
 
            System.out.println(a[i].getId()+"   "+a[i].getNombre()+"   "+a[i].getSueldo());
 
        }
 
    }
 
}


clase empleado


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package quicksort;
 
 
 
public class empleado {
 
   //  int id;
 
    //rivate String nombre;
 
     //int sueldo;
 
    private int id;
 
    private String nombre;
 
    private int sueldo;
 
 
 
    public empleado(String nombre, int id, int sueldo) {
 
        this.id = id;
 
        this.nombre = nombre;
 
        this.sueldo = sueldo;
 
    }
 
 
 
    public empleado() {
 
        nombre="";
 
        id=0;
 
        sueldo=0;
 
    }
 
 
 
    public int getId() {
 
        return id;
 
    }
 
 
 
    public void setId(int id) {
 
        this.id = id;
 
    }
 
 
 
    public  String getNombre() {
 
        return nombre;
 
    }
 
 
 
    public void setNombre(String nombre) {
 
        this.nombre = nombre;
 
    }
 
 
 
    public int getSueldo() {
 
        return sueldo;
 
    }
 
 
 
    public void setSueldo(int sueldo) {
 
        this.sueldo = sueldo;
 
    }
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 11
Ha disminuido 1 puesto en Netbeans (en relación al último mes)
Gráfica de Netbeans

Quicksort

Publicado por Yamil Bracho (6 intervenciones) el 25/04/2016 22:32:48
Aqui tienes una explicacion y un pseudocodigo del algoritmo

https://es.wikipedia.org/wiki/Quicksort
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar