题解 | #矩阵转置#
矩阵转置
https://www.nowcoder.com/practice/351b3d03e410496ab5a407b7ca3fd841
#include <stdio.h> int main() { int n, m, i, j; scanf("%d%d", &n, &m); int arr[100]; int sz = n * m; for (i = 0; i < sz; i++) { scanf("%d", &arr[i]); } for (i = 0; i < m; i++) { //m=3 n=2 int c = 0; for (j = i; j <= i + m*(n-1); j = j + m) { printf("%d ", arr[j]); c++; } if (c % n == 0)// 1 2 printf("\n"); } return 0; }