Ubgrade 10.11.
parent
646b6baf5e
commit
873b41722c
|
@ -9,6 +9,27 @@ import java.util.Random;
|
||||||
public class InsertionSort
|
public class InsertionSort
|
||||||
{
|
{
|
||||||
public static void InsertionSort(){
|
public static void InsertionSort(){
|
||||||
|
Random rand = new Random();
|
||||||
|
int [] Array = new int [4];
|
||||||
|
|
||||||
|
//Array befühlen
|
||||||
|
for(int i = 0; i<Array.length; i++){
|
||||||
|
Array[i] = rand.nextInt(50);
|
||||||
|
|
||||||
|
}
|
||||||
|
//Array ausgeben
|
||||||
|
System.out.println("Array:");
|
||||||
|
for(int i = 0; i<Array.length; i++){
|
||||||
|
System.out.println(+Array[i]);
|
||||||
|
}
|
||||||
|
//Vergleichen und Vertauschen
|
||||||
|
for(int i = 0; i<Array.length; i++){
|
||||||
|
for(int j = i+1; j<Array.length; j++){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* @version (eine Versionsnummer oder ein Datum)
|
* @version (eine Versionsnummer oder ein Datum)
|
||||||
*/
|
*/
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
public class Sortierung
|
public class SelectionSort
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -48,7 +48,8 @@ public class Sortierung
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int MinimumPosition(int [] Array){
|
public static int MinimumPosition(int[]Array){
|
||||||
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
for(int i = 0; i< Array.length; i++){
|
for(int i = 0; i< Array.length; i++){
|
||||||
if(Array[i] < Array[x])
|
if(Array[i] < Array[x])
|
||||||
|
@ -56,6 +57,7 @@ public class Sortierung
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void SelectionSortInPlace(){
|
public static void SelectionSortInPlace(){
|
Loading…
Reference in New Issue