fork download
  1. import java.util.*;
  2.  
  3. public class sortieren {
  4. private static int partition(int li, int re, int[] arr) {
  5. int pivot = arr[re];
  6.  
  7. int a = li;
  8. int b = re;
  9. while (true) {
  10. while (a < b && arr[a] < pivot) {
  11. a++;
  12. }
  13. while (b > a && arr[b] >= pivot) {
  14. b--;
  15. }
  16.  
  17. if (a >= b)
  18. break;
  19.  
  20. // vertausche arr[a] und arr[b]
  21.  
  22. int t = arr[a];
  23. arr[a] = arr[b];
  24. arr[b] = t;
  25. }
  26.  
  27. arr[re] = arr[b];
  28. arr[b] = pivot;
  29. return b;
  30. }
  31.  
  32. public static void qs(int li, int re, int[] arr) {
  33. if (li >= re)
  34. return;
  35. int i = partition(li, re, arr);
  36.  
  37. qs(li, i - 1, arr);
  38. qs(i + 1, re, arr);
  39. }
  40.  
  41. public static void main(String[] args) {
  42. int arr[] = { 4, 9, 7, 2, 0, 6, 3, 5, 8, 1 };
  43.  
  44. qs(0, arr.length - 1, arr);
  45. System.out.println(Arrays.toString(arr));
  46. }
  47.  
  48. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: class sortieren is public, should be declared in a file named sortieren.java
public class sortieren {
       ^
1 error
stdout
Standard output is empty