L7 - C

public
yeskendir.sultanov Mar 27, 2024 Never 86
Clone
C++ l7c.cpp 28 lines (25 loc) | 566 Bytes
1
#include <bits/stdc++.h>
2
3
using namespace std;
4
5
int main() {
6
int n;
7
cin >> n;
8
int a[n][n];
9
for (int i = 0; i < n; ++i) {
10
for (int j = 0; j < n; ++j) {
11
if (i == j) {
12
a[i][j] = 0;
13
} else if (i < j) {
14
a[i][j] = 1;
15
} else {
16
a[i][j] = 2;
17
}
18
}
19
}
20
21
for (int i = 0; i < n; ++i) {
22
for (int j = 0; j < n; ++j) {
23
cout << a[i][j] << ' ';
24
}
25
cout << endl;
26
}
27
return 0;
28
}