Bubblesort implementiert aus der VL

test
student 2026-03-25 12:40:15 +01:00
parent ad254868f9
commit f49cf045de
3 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,27 @@
public static void main(String[] args){
}
public static void bubblesort(int[] arr){
/// aus der Vorlesung:
boolean ready = false;
while (!ready) {
ready = true;
for (int i = 0; i < arr.length -1; i++) {
if (arr[i] > arr[i+1]) {
ready = false;
int m = arr[i];
arr[i] = arr[i+1];
arr[i+1] = m;
} // if
} // for
System.out.println(Arrays.toString(arr));
} // while
}

13
src/src/Main.java 100644
View File

@ -0,0 +1,13 @@
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
void main() {
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
// to see how IntelliJ IDEA suggests fixing it.
IO.println(String.format("Hello and welcome!"));
for (int i = 1; i <= 5; i++) {
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
IO.println("i = " + i);
}
}

View File

@ -1,3 +1,5 @@
public static void main(String[] args){
System.out.println("Test");
}