fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12.  
  13. int arr[] = {15, 19, 23, 17, 13, 12, 45, 67, 23, 33};
  14. int temp = 0;
  15. boolean x = true;
  16.  
  17. while(x) {
  18. x = false;
  19.  
  20. for (int i = 0; i < 9; i++) {
  21.  
  22. if (arr[i] > arr[i+1]) {
  23. temp = arr[i];
  24. arr[i] = arr[i+1];
  25. arr[i+1] = temp;
  26. x = true;
  27. }
  28.  
  29. }
  30.  
  31.  
  32. }
  33.  
  34. for (int j = 0; j < 10; j++) {
  35. System.out.println(arr[j]);
  36. }
  37.  
  38.  
  39.  
  40. }
  41. }
Success #stdin #stdout 0.06s 32448KB
stdin
Standard input is empty
stdout
12
13
15
17
19
23
23
33
45
67