题解 | #矩阵转置#
矩阵转置
https://www.nowcoder.com/practice/351b3d03e410496ab5a407b7ca3fd841
#include <stdio.h> int main() { int n = 0;//行 int m = 0;//列 scanf("%d %d", &n, &m);//输入 int arr1[n][m]; int i = 0; for (i = 0; i < n; i++)//遍历输入 { int j = 0; for (j = 0; j < m; j++) { scanf("%d ", &arr1[i][j]); } } int arr2[m][n]; for (i = 0; i < n; i++)//转置 { int j = 0; for (j = 0; j < m; j++) { arr2[j][i]=arr1[i][j]; } } for (i = 0; i < m; i++)//打印输出 { int j = 0; for (j = 0; j < n; j++) { printf("%d ", arr2[i][j]); } printf("\n"); } return 0; }
C语言基础 文章被收录于专栏
里面较为详细的介绍了c语言的相关用法和有关题目。