T427570 【小任务】行列转换
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
struct Node{
|
||||
int first;
|
||||
int second;
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
int x[10][10], n, m, k, a, b, c;
|
||||
int main() {
|
||||
cin >> n >> m >> k;
|
||||
for (int i = 0; i < k; i++) {
|
||||
cin >> a >> b >> c;
|
||||
x[a][b] = c; // 行优先
|
||||
}
|
||||
for (int i = 1; i <= m; i++) { // 列优先(i=列,j=行)
|
||||
for (int j = 1; j <= n; j++) {
|
||||
if (x[j][i] != 0) { // j=行 ,i=列
|
||||
cout << x[j][i] << " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user