fork download
  1. import java.util.Arrays;
  2. class Decision{
  3. public static void main (String[]args){
  4. int[] myArray = {1,8,9,10,0};
  5.  
  6. for(int n=myArray.length; n>1; n=n-1){
  7. System.out.println("Outer loop: " + n);
  8. for(int i=0; i<myArray.length-1; i++){
  9. if(myArray[i]<myArray[i+1]){
  10. }
  11. else{
  12. int temp=myArray[i];
  13. myArray[i]=myArray[i+1];
  14. myArray[i+1]=temp;
  15. }
  16. System.out.println(Arrays.toString(myArray));
  17. }
  18. }
  19. }
  20. }
Success #stdin #stdout 0.03s 711168KB
stdin
Standard input is empty
stdout
Outer loop: 5
[1, 8, 9, 10, 0]
[1, 8, 9, 10, 0]
[1, 8, 9, 10, 0]
[1, 8, 9, 0, 10]
Outer loop: 4
[1, 8, 9, 0, 10]
[1, 8, 9, 0, 10]
[1, 8, 0, 9, 10]
[1, 8, 0, 9, 10]
Outer loop: 3
[1, 8, 0, 9, 10]
[1, 0, 8, 9, 10]
[1, 0, 8, 9, 10]
[1, 0, 8, 9, 10]
Outer loop: 2
[0, 1, 8, 9, 10]
[0, 1, 8, 9, 10]
[0, 1, 8, 9, 10]
[0, 1, 8, 9, 10]