fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. int A[20][20];
  8. for (int i = 0; i < n; i++){
  9. for (int j = 0; j < n; j++){
  10. if(i + j == n - 1) A[i][j] = 0;
  11. else if (i + j < n - 1) A[i][j] = 2;
  12. else A[i][j] = 1;
  13. }
  14. }
  15. for (int i = 0; i < n; i++){
  16. for (int j = 0; j < n; j++)
  17. cout << A[i][j];
  18. cout << endl;
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 4252KB
stdin
3
stdout
220
201
011