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;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/376966.html
標籤:其他
上一篇:高級密碼學復習1-HUST版
