fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 50;
  5.  
  6. int main() {
  7. int n;
  8. cin >> n;
  9. int max = n + 1;
  10. for (int i = 1; i <= n; ++i) {
  11. for (int j = 1; j <= n; ++j) {
  12. if (i == j || i + j == max) {
  13. cout << "0 ";
  14. } else if (i < j && i + j < max) {
  15. cout << "1 ";
  16. } else if (i > j && i + j < max) {
  17. cout << "4 ";
  18. } else if (i < j && i + j > max) {
  19. cout << "2 ";
  20. } else if (i > j && i + j > max) {
  21. cout << "3 ";
  22. }
  23. }
  24. cout << "\n";
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5500KB
stdin
4
stdout
0 1 1 0 
4 0 0 2 
4 0 0 2 
0 3 3 0