mirror of
https://gitlab.com/tutorial-java-rafa-munoz/tutorial-java-2024-25/tutorialjava2024-25.git
synced 2025-11-09 18:03:09 +01:00
feat(examen 20241025): solved
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package tutorialJava.examenes.examen20241025;
|
||||
|
||||
import tutorialJava.UtilsArrays;
|
||||
|
||||
public class EjD_OrdenacionEntreLimites {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int a[] = new int[15];
|
||||
|
||||
UtilsArrays.inicializaArray(a, 0, 100);
|
||||
UtilsArrays.imprimeArray(a);
|
||||
ordenaBurbuja(a, 2, 8);
|
||||
UtilsArrays.imprimeArray(a);
|
||||
}
|
||||
|
||||
|
||||
public static void ordenaBurbuja(int a[], int limInf, int limSup) {
|
||||
boolean hayIntercambios = false;
|
||||
do {
|
||||
hayIntercambios = false;
|
||||
for (int i = limInf; i <= limSup; i++) {
|
||||
if (a[i] > a[i + 1]) {
|
||||
int aux = a[i];
|
||||
a[i] = a[i + 1];
|
||||
a[i + 1] = aux;
|
||||
hayIntercambios = true;
|
||||
}
|
||||
}
|
||||
} while (hayIntercambios == true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user