mirror of
https://github.com/13hannes11/archive.git
synced 2024-09-03 21:50:58 +02:00
added all past projects
This commit is contained in:
48
Java/Bubblesort/src/bubblesort/Bubblesort.java
Normal file
48
Java/Bubblesort/src/bubblesort/Bubblesort.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package bubblesort;
|
||||
public class Bubblesort {
|
||||
static double[] arr = new double[400000];
|
||||
static int start = 0, ende = arr.length - 1;
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO code application logic here
|
||||
fillArray();
|
||||
|
||||
while(start != ende)
|
||||
{
|
||||
int aktuelles = start;
|
||||
int bestes = start;
|
||||
|
||||
do {
|
||||
aktuelles++;
|
||||
if(bestes < aktuelles)
|
||||
{
|
||||
bestes = aktuelles;
|
||||
}
|
||||
} while (aktuelles != ende);
|
||||
tausche(bestes, start);
|
||||
|
||||
}
|
||||
//ausgabe();
|
||||
|
||||
|
||||
}
|
||||
public static void ausgabe()
|
||||
{
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
System.out.println(arr[i]);
|
||||
}
|
||||
}
|
||||
public static void tausche(int zeiger1, int zeiger2)
|
||||
{
|
||||
double tmp = arr[zeiger1];
|
||||
arr[zeiger1] = arr[zeiger2];
|
||||
arr[zeiger2] = tmp;
|
||||
start++;
|
||||
}
|
||||
public static void fillArray()
|
||||
{
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
arr[i] = Math.random();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user