题解 | 矩阵转置

矩阵转置

https://www.nowcoder.com/practice/351b3d03e410496ab5a407b7ca3fd841

#include <iostream>
#define SIZE 100
#include<array>
using namespace std;

int main() {
   int m,n;
  std::array<std::array<int,SIZE>, SIZE> arr ;
   cin>>n>>m;
   for(int i=0;i<n;i++)
   {
    for(int j=0;j<m;j++)
    {
        cin>>arr[i][j];   
    }
   }
  for (int j = 0; j < m; j++)//列
{
    for (int i = 0; i < n; i++)//行
    {
        cout << arr[i][j]<<" ";
    }
    printf("\n");
}
}

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务