Java - Ordenamiento Burbuja

 
Vista:
sin imagen de perfil

Ordenamiento Burbuja

Publicado por Juanjo (1 intervención) el 07/04/2007 19:41:54
este es un ejercicio de clase usando el metodo de ordenamiento de burbuja pero nu me sale.. aqui se los dejo y si pueden publican el error q eh cometido para poder corregirlo...
de ante mano gracias a todos por el apoyo

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
/*utilizacion del Metodo de ordenacion "burbuja"y el ingreso debe ser por ventanas */
import java.io.*;
class BuscaBurbuja
{
    public static void main(String arg[]) throws IOException
    {
        /*creacion del objeto para leer por teclado*/
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        /*ingreso del tamaño de arreglos*/
        System.out.print("\n Ingrese Numero de Datos a Ingresar : ");
        int tam = Integer.parseInt(in.readLine());
        /*creacion del arreglo*/
        int arr[] = new int[tam];
        System.out.println();
        /*lectura del arreglo*/
        int j = 0;
        for (int i = 0 ; i < arr.length;i++)
        {
            j+=1;
            System.out.print("Elemento " + j + " : ");
            arr[i] = Integer.parseInt(in.readLine());
        }
     burbuja(arr);
    }
     static void burbuja(int arreglo[])
    {
        for(int i = 0; i < arreglo.length - 1; i++)
        {
            for(int j = 0; j < arreglo.length - 1; i++)
            {if (arreglo[j] < arreglo[j + 1])
                {
                int tmp = arreglo[j+1];
                arreglo[j+1] = arreglo[j];
                arreglo[j] = tmp;
                }
            }
        }
        String Mostrar = " ";
        for(int i = 0;i < arreglo.length; i++)
        Mostrar = Mostrar + ", " + i;
    }
}
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

RE:Ordenamiento Burbuja

Publicado por -.- (13 intervenciones) el 09/04/2007 00:46:03
{
for(int i = 0; i < arreglo.length - 1; i++) <--
{
for(int j = 0; j < arreglo.length - 1; i++) <--?? i?
{if (arreglo[j] < arreglo[j + 1])
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