题解
2024-10-19 14:36:52
发布于:江苏
6阅读
0回复
0点赞
#include <iostream>
#include <iomanip> // for setw and setfill
using namespace std;
const int MAXN = 105;
int n, m;
int arr[MAXN][MAXN];
int num[MAXN];
int main() {
cin >> n >> m;
// 读取矩阵
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin >> arr[i][j];
}
}
// 读取新的行号顺序
for (int i = 1; i <= n; ++i) {
cin >> num[i];
}
// 按照新的行号顺序输出矩阵
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cout << setw(3) << setfill('0') << arr[num[i]][j] << " ";
}
cout << "\n";
}
return 0;
}
全部评论 1
顶
2024-10-19 来自 江苏
0
有帮助,赞一个