fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5.  
  6. class Main
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. Scanner in = new Scanner(System.in);
  11. int n = in.nextInt();
  12. int[][] arr = new int [20][20];
  13. for (int i = 0; i < n; i++){
  14. for (int j = 0; j < n; j++){
  15. if(i + j == n - 1) arr[i][j] = 0;
  16. else if (i + j < n - 1) arr[i][j] = 2;
  17. else arr[i][j] = 1;
  18. }
  19. }
  20. for (int i = 0; i < n; i++){
  21. for (int j = 0; j < n; j++){
  22. System.out.print(arr[i][j]);
  23. }
  24. System.out.println();
  25. }
  26. }
  27. }
Success #stdin #stdout 0.07s 2184192KB
stdin
2
stdout
20
01