AcWing 754. 平方矩阵 II
原题链接
简单
作者:
SayYong
,
2024-10-06 22:56:00
,
所有人可见
,
阅读 2
#include <iostream>
using namespace std;
const int N = 110;
int arr[N][N];
int main(void)
{
int n;
while (cin >> n) {
if (n == 0) break;
for (int i = 0; i < n; i++) {
arr[0][i] = i + 1;
arr[i][0] = i + 1;
}
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
arr[i][j] = arr[i-1][j-1];
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cout << arr[i][j] << ' ';
}
cout << endl;
}
cout << endl;
}
return 0;
}