Urgente- Ajuda vetor

2 respostas
dinorah

2 Respostas

thiagofesta

http://pt.wikipedia.org/wiki/Bubble_sort

Usa ai, tem exemplo em java até!!

public static void bubbleSort(int[] a) {
  for (int i = 0; i < a.length-1; i++) {
     for (int j = 0; j < a.length-i-1; j++) {
        if (a[j] > a[j+1]) {
           swap(a, j, j+1);
        }
     }
  }
}

private static void swap(int[] a, int i, int j) {
  int temp = a[i];
  a[i] = a[j];
  a[j] = temp;
}
thiagofesta

Outra coisa…
Deixa seu código entra as tags BB de código!
Fica melhor para conseguirmos ler

Criado 27 de outubro de 2008
Ultima resposta 27 de out. de 2008
Respostas 2
Participantes 2