fork download
  1. public static void shiningBubblesort(int[] a) {
  2. int l = 0;
  3. int u = a.length - 1;
  4.  
  5. while (l < u) {
  6. int up = u;
  7. for (int i = l; i < u; i++) {
  8. if (a[i] > a[i + 1]) {
  9. int t = a[i];
  10. a[i] = a[i + 1];
  11. a[i + 1] = t;
  12. up = i;
  13. }
  14. }
  15. u = up;
  16.  
  17. int lp = u;
  18. for (int i = u; i > l; i--) {
  19. if (a[i - 1] > a[i]) {
  20. int t = a[i - 1];
  21. a[i - 1] = a[i];
  22. a[i] = t;
  23. lp = i;
  24. }
  25. }
  26. l = lp;
  27. }
  28. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty