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. int[][] matrix = new int[8][8];
  13. int count = matrix[0].length - 1;
  14. int xcurr = 0;
  15. int ycurr = count;
  16.  
  17. for(int x=0; x < matrix[0].length; x++) {
  18. for (int y=0; y < matrix[0].length; y++) {
  19. if (x == xcurr && y == ycurr) {
  20. matrix[x][y] = count;
  21. ycurr --;
  22. xcurr ++;
  23. count --;
  24. } else {
  25. matrix[x][y] = 0;
  26. }
  27. }
  28. }
  29.  
  30. for(int i=0; i < matrix.length; i++) {
  31. System.err.println(Arrays.toString(matrix[i]));
  32. }
  33. }
  34.  
  35. }
Success #stdin #stdout #stderr 0.1s 320256KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
[0, 0, 0, 0, 0, 0, 0, 7]
[0, 0, 0, 0, 0, 0, 6, 0]
[0, 0, 0, 0, 0, 5, 0, 0]
[0, 0, 0, 0, 4, 0, 0, 0]
[0, 0, 0, 3, 0, 0, 0, 0]
[0, 0, 2, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0]