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. { int n;
  12. Scanner sc = new Scanner(System.in);
  13. n=sc.nextInt();
  14. int[][] matrix;
  15. matrix = new int[n][n];
  16. for(int i=0;i < n;i++){
  17. matrix[i][i]=1;
  18. }
  19. for(int i=0;i<n;i++){
  20. for(int y=0;y<n;y++){
  21. if(matrix[i][y]!=1){
  22. matrix[i][y]=0;
  23. }
  24. }
  25. }
  26. for(int i=0;i<n;i++){
  27. for(int y=0;y<n;y++){
  28. System.out.print(matrix[i][y]);
  29. }
  30. System.out.println("\n");
  31. }
  32. }
  33. }
Success #stdin #stdout 0.08s 711680KB
stdin
45 451 45 5 5 4 12  561  1 64 7 8 9 54 4 654 984 6 89 56 9 86 6 898 56 89 816 55 43 263   568 59 89 6 45 46 65 98 95
stdout
100000000000000000000000000000000000000000000

010000000000000000000000000000000000000000000

001000000000000000000000000000000000000000000

000100000000000000000000000000000000000000000

000010000000000000000000000000000000000000000

000001000000000000000000000000000000000000000

000000100000000000000000000000000000000000000

000000010000000000000000000000000000000000000

000000001000000000000000000000000000000000000

000000000100000000000000000000000000000000000

000000000010000000000000000000000000000000000

000000000001000000000000000000000000000000000

000000000000100000000000000000000000000000000

000000000000010000000000000000000000000000000

000000000000001000000000000000000000000000000

000000000000000100000000000000000000000000000

000000000000000010000000000000000000000000000

000000000000000001000000000000000000000000000

000000000000000000100000000000000000000000000

000000000000000000010000000000000000000000000

000000000000000000001000000000000000000000000

000000000000000000000100000000000000000000000

000000000000000000000010000000000000000000000

000000000000000000000001000000000000000000000

000000000000000000000000100000000000000000000

000000000000000000000000010000000000000000000

000000000000000000000000001000000000000000000

000000000000000000000000000100000000000000000

000000000000000000000000000010000000000000000

000000000000000000000000000001000000000000000

000000000000000000000000000000100000000000000

000000000000000000000000000000010000000000000

000000000000000000000000000000001000000000000

000000000000000000000000000000000100000000000

000000000000000000000000000000000010000000000

000000000000000000000000000000000001000000000

000000000000000000000000000000000000100000000

000000000000000000000000000000000000010000000

000000000000000000000000000000000000001000000

000000000000000000000000000000000000000100000

000000000000000000000000000000000000000010000

000000000000000000000000000000000000000001000

000000000000000000000000000000000000000000100

000000000000000000000000000000000000000000010

000000000000000000000000000000000000000000001