Informatikks1/Minimumsuche.java

68 lines
1.3 KiB
Java

import java.util.Random;
public class Minimumsuche
{
public static void Minimumsuche()
{
Random r = new Random();
int[] a = new int[20];
for (int i= 0; i< a.length; i++)
{
a[i] = r.nextInt(50);
}
for (int i = 0; i < a.length; i++)
{
System.out.print(a[i]);
System.out.print(",");
}
System.out.println();
int[]sortiert = new int[a.length];
for (int i = 0; i< a.length; i++)
{
int index = Minimum(a);
sortiert[i] = a[index];
a[index] = 99;
}
for( int i= 0; i< sortiert.length; i++)
{
System.out.println(sortiert[i]);
System.out.println(",");
}
System.out.println();
}
public static int Minimum(int [] a)
{
System.out.println();
int min = 99;
int minindex = min;
for(int i = 0; i < a.length; i++)
{
if (a[i] < min)
{
min = a[i];
minindex = i;
}
}
return minindex;
int goofahh = 0;
for (int i = 0; i < a.lenth;i++)
{
if (a[i] < goofahh)
{
goofahh = a[i];
}
}
}
}