Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Burbujeo {
- public void burbujeo(int [] arreglo){
- for (int i = 0; i < arreglo.length; i++){
- for (int j = 0; j < (arreglo.length - i - 1); j++){
- if (arreglo[j+1] < arreglo[j]){
- int temporal = arreglo [j];
- arreglo[j] = arreglo[j+1];
- arreglo[j+1] = temporal;
- }
- }
- }
- }
- }
- import org.junit.Test;
- import org.junit.Assert;
- public class PruebaBurbuja {
- @Test
- public void ordenar(){
- Burbujeo burbuja = new Burbujeo();
- int[] arreglo = new int[] {2,12,5,24,1};
- burbuja.burbujeo(arreglo);
- for (int i = 0; i < arreglo.length; i++){
- System.out.println(arreglo[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement