题解 | #矩阵转置#
矩阵转置
https://www.nowcoder.com/practice/351b3d03e410496ab5a407b7ca3fd841
#include <stdio.h> #define M 10 #define N 10 int main() { int m = 0; int n = 0; while (2 == scanf("%d %d", &n, &m)) { int arr[N][M] = {0}; // 输入 for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &arr[i][j]); } } // 输出 for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { printf("%d ", arr[j][i]); } printf("\n"); } } return 0; }