Auswertung hinzugefügt

This commit is contained in:
Marc Koch 2020-05-08 10:17:22 +02:00
parent e29bb7323f
commit 5f6388a787
Signed by: marc
GPG Key ID: AC2D4E00990A6767
1 changed files with 5 additions and 5 deletions

View File

@ -18,14 +18,14 @@ public class Main {
boolean fertig = false; boolean fertig = false;
int temp = 0; int temp = 0;
int zaehlerDurchlaeufe = 0; int zaehlerPruefungen = 0;
int zaehlerTauschvorgaenge = 0; int zaehlerTauschvorgaenge = 0;
while (!fertig) { while (!fertig) {
for (int i = 0; i < array.length - 1; i++) { for (int i = 0; i < array.length - 1; i++) {
zaehlerDurchlaeufe++; zaehlerPruefungen++;
fertig = true; fertig = true;
if (array[i] > array[i + 1]) { if (array[i] > array[i + 1]) {
@ -34,6 +34,7 @@ public class Main {
array[i] = array[i + 1]; array[i] = array[i + 1];
array[i + 1] = temp; array[i + 1] = temp;
zaehlerTauschvorgaenge++; zaehlerTauschvorgaenge++;
zaehlerPruefungen++;
for (int j = i; j > 0; j--) { for (int j = i; j > 0; j--) {
if (array[j] < array[j - 1]) { if (array[j] < array[j - 1]) {
@ -46,7 +47,6 @@ public class Main {
} }
} }
break;
} }
if (i == array.length - 1) { if (i == array.length - 1) {
@ -56,7 +56,7 @@ public class Main {
} }
System.out.println("\nTauschvorgänge: " + zaehlerTauschvorgaenge); System.out.println("\nTauschvorgänge: " + zaehlerTauschvorgaenge);
System.out.println("Durchläufe: " + zaehlerDurchlaeufe); System.out.println("Prüfungen: " + zaehlerPruefungen);
return array; return array;
} }