12.11.
							parent
							
								
									b39587b4d5
								
							
						
					
					
						commit
						b142516902
					
				|  | @ -20,18 +20,23 @@ public class InsertionSort | ||||||
|       //Array ausgeben
 |       //Array ausgeben
 | ||||||
|       System.out.println("Array:"); |       System.out.println("Array:"); | ||||||
|      for(int i = 0; i<Array.length; i++){ |      for(int i = 0; i<Array.length; i++){ | ||||||
|         System.out.println(+Array[i]); |         System.out.println(Array[i]); | ||||||
|         } |         } | ||||||
|         //Vergleichen und Vertauschen
 |         //Vergleichen und Vertauschen
 | ||||||
|         System.out.println("Sortierter Array:"); |         System.out.println("Sortierter Array:"); | ||||||
|         for(int i = 0; i<Array.length; i++){ |        for(int i = 0; i<Array.length; i++){ | ||||||
|         int ArrayToSort = Array[i]; |         int Wert = Array[i]; | ||||||
|         int j = i; |         int j = i -1 ; | ||||||
|         while(ArrayToSort < Array[j+1]){ |         while(j >= 0 && Array[j] >Wert ){ | ||||||
|         Array[j] = Array[j-1]; |         Array [j] = Array[j + 1]; | ||||||
|  |          | ||||||
|  |         System.out.println(Array[j+1] ); | ||||||
|  |          | ||||||
|         } |         } | ||||||
|         Array[j] = ArrayToSort; |         while(j>=0 && Array[j] < Wert){ | ||||||
|         System.out.println(ArrayToSort); |         System.out.print(Array[i]); | ||||||
|  |         } | ||||||
|  |         System.out.println(); | ||||||
|          |          | ||||||
|         } |         } | ||||||
|          |          | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| 
 | 
 | ||||||
| public class __SHELL11 extends bluej.runtime.Shell { | public class __SHELL37 extends bluej.runtime.Shell { | ||||||
| public static void run() throws Throwable { | public static void run() throws Throwable { | ||||||
| 
 | 
 | ||||||
| InsertionSort.InsertionSort(); | InsertionSort.InsertionSort(); | ||||||
		Loading…
	
		Reference in New Issue