master
freverda 2022-11-12 17:21:12 +01:00
parent b39587b4d5
commit b142516902
2 changed files with 14 additions and 9 deletions

View File

@ -20,18 +20,23 @@ public class InsertionSort
//Array ausgeben
System.out.println("Array:");
for(int i = 0; i<Array.length; i++){
System.out.println(+Array[i]);
System.out.println(Array[i]);
}
//Vergleichen und Vertauschen
System.out.println("Sortierter Array:");
for(int i = 0; i<Array.length; i++){
int ArrayToSort = Array[i];
int j = i;
while(ArrayToSort < Array[j+1]){
Array[j] = Array[j-1];
int Wert = Array[i];
int j = i -1 ;
while(j >= 0 && Array[j] >Wert ){
Array [j] = Array[j + 1];
System.out.println(Array[j+1] );
}
Array[j] = ArrayToSort;
System.out.println(ArrayToSort);
while(j>=0 && Array[j] < Wert){
System.out.print(Array[i]);
}
System.out.println();
}

View File

@ -1,5 +1,5 @@
public class __SHELL11 extends bluej.runtime.Shell {
public class __SHELL37 extends bluej.runtime.Shell {
public static void run() throws Throwable {
InsertionSort.InsertionSort();