1 条题解

  • 0
    @ 2022-10-9 10:58:11
    #include <bits/stdc++.h>
    using namespace std;
    int n, m;
    int a[105][105], b[105][105];
    int main()
    {
    	//输入 
        cin >> n >> m;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++)
                cin >> a[i][j];
        //转置: b[i][j] = a[j][i] 
        for (int i = 1; i <= m; i++)
            for (int j = 1; j <= n; j++)
                b[i][j] = a[j][i];
        //输出 
        for (int i = 1; i <= m; i++)
        {
            for (int j = 1; j <= n; j++)
                cout << b[i][j] << " ";
            cout << "\n";
        }
        return 0;
    }
    
    /*
    a[1][1] a[1][2]
    a[2][1] a[2][2]
    a[3][1] a[3][2] 
    
    a[1][1] a[2][1] a[3][1]
    a[1][2] a[2][2] a[3][2]
    
    b[1][1] b[1][2] b[1][3]
    b[2][1] b[2][2] b[2][3]
    */
    
    
    • 1

    信息

    ID
    346
    时间
    1000ms
    内存
    128MiB
    难度
    3
    标签
    (无)
    递交数
    96
    已通过
    53
    上传者