简单题日常3:f1813:矩阵转置

  • Post author:
  • Post category:其他

1813: 矩阵转置

时间限制: 1 Sec  内存限制: 128 MB
提交: 391  解决: 197
[提交][状态][讨论版]

题目描述

将一个矩阵进行转置(即原来的行变为列),如

输入n=3 m=4的矩阵

3 4
5 2 0 9
3 7 12 6
10 4 1 8

输出为(4行3列)

4 3
5 3 10
2 7 4
0 12 1
9 6 8

输入

输出

提示

 n,m不超过10

来源

简单二维数组

[提交][状态][讨论版]

한국어  中文  فارسی  English  ไทย
Anything about the Problems, Please Contact :Administrator
All Copyright Reserved 2010-2014 福建师大附中 TEAM
GPL2.0 2003-2013 HUSTOJ Project TEAM

#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;
int a[1001][1001];
int main()
{
int m,n;
cin>>n>>m;
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j)
cin>>a[i][j];
cout<<m<<" "<<n<<endl;
for(int i=1;i<=m;++i)
{
	for(int j=1;j<=n;++j)
	cout<<a[j][i]<<" ";
	cout<<endl;
}

return 0;
}


版权声明:本文为Deco00ffcc原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。