c++数组-矩阵的转置

#include <iostream>
using namespace std;
int main(){
    int a[2][3]={{1,2,3},{4,5,6}};
    int i,j,b[3][2];
    for(j=0;j<2;j++){
        for(i=0;i<3;i++){
            cout<<a[j][i]<<" ";
            b[i][j]=a[j][i];
        }
        cout<<endl;
    }
    cout<<"array b:"<<endl;
    for(i=0;i<3;i++){
        for(j=0;j<2;j++){
            cout<<b[i][j]<<" ";
        }
        cout<<endl;
    }
    system("PAUSE");
    return 0;
}

运行结果

1 2 3
4 5 6
array b:
1 4
2 5
3 6
请按任意键继续. . .
原文地址:https://www.cnblogs.com/walter371/p/4050814.html