AcWing 3592. 矩阵转置
原题链接
简单
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 110;
int t, n, m, k, l, r, op, x, y;
int f[N][N];
bool flag;
void solve() {
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> f[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
t = f[i][j];
f[i][j] = f[j][i];
f[j][i] = t;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cout<<f[i][j]<<" ";
}
cout<<"\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}