Skip to content

Instantly share code, notes, and snippets.

@JMGama
Last active April 4, 2017 05:04
Show Gist options
  • Save JMGama/7efe891023e75f46fd1168393f75f612 to your computer and use it in GitHub Desktop.
Save JMGama/7efe891023e75f46fd1168393f75f612 to your computer and use it in GitHub Desktop.
Bubble method in java
public static void burbuja(int[] Arreglo) {
int i, j, aux;
for (i = 0; i < Arreglo.length -1; i++) {
for (j = 0; j < Arreglo.length -1; j++) {
if (Arreglo[j] > Arreglo[j + 1]) {
aux = Arreglo[j];
Arreglo[j] = Arreglo[j + 1];
Arreglo[j + 1] = aux;
}
}
}
for(i = 0; i< Arreglo.length; i++){
System.out.println(Arreglo[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment