#32373: C++


jf5162287@gmail.com (Reach the pinnacle)

學校 : 不指定學校
編號 : 208401
來源 : [60.198.146.161]
最後登入時間 :
2023-05-23 01:08:50
a015. 矩陣的翻轉 | From: [106.64.122.99] | 發表日期 : 2022-10-04 17:32

#include <iostream>
using namespace std;

int main()
{
    int matrix[100][100];
    int row,col;
    while (cin >> row >> col){
        for (int i=0;i<row;++i){
            for (int j=0;j<col;++j){
                cin >> matrix[i][j];
            }
        }
    
        for (int i=0;i<col;++i){
            for (int j=0;j<row;++j){
                cout << matrix[j][i];  //矩陣翻轉所以此處要改成[j][i]
                if (j != row - 1){     //判斷空格
                    cout << " ";
                }
            }
            cout << endl;
        }
    }
    return 0;
}

 
ZeroJudge Forum