AcWing 755. 平方矩阵 III
原题链接
简单
作者:
1163174296
,
2024-11-14 21:55:19
,
所有人可见
,
阅读 1
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main() {
int n;
int a[100][100];
while (cin >> n, n) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
a[i][j] = 0;
}
}
for (int i = 0; i < n; i++) {
a[i][i] = pow(4, i);
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i != j) {
a[i][j] = a[i][i] * pow(2, abs(i - j));
}
}
}
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) {
a[j][i] = a[i][j];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cout << a[i][j] << ' ';
}
cout << endl;
}
cout << endl;
}
return 0;
}
我咋这么笨呢