fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. int [] matrix = new int[5];
  14. matrix[0] = 2;
  15. matrix[1] = 3;
  16. matrix[2] = 0;
  17. matrix[3] = 1;
  18. matrix[4] = 0;
  19. int temp;
  20. for(int i=1;i < matrix.length;i++){
  21. for (int j=0 ; j < matrix.length- 1; j++){
  22. if (matrix[j] == 0){
  23. temp = matrix[j];
  24. matrix[j] = matrix[j+1];
  25. matrix[j+1] = temp;
  26. }
  27. }
  28. }
  29. for (int i = 0; i<matrix.length;i++)
  30. {
  31. System.out.println(matrix[i]);
  32. System.out.println("\n");
  33. }
  34. }
  35. }
Success #stdin #stdout 0.03s 711168KB
stdin
Standard input is empty
stdout
2


3


1


0


0