#32197: 誰能幫我一下:(


jason096727@gmail.com (Jason Ho)

學校 : 高雄市苓雅區福東國民小學
編號 : 189939
來源 : [150.116.71.76]
最後登入時間 :
2023-07-15 21:32:51
b965. 2. 矩陣轉換 -- 2016年3月apcs | From: [150.116.68.223] | 發表日期 : 2022-09-20 22:31

#include <iostream>

using namespace std;

int r, c, m, num[10][10], temp[10][10];

void zero(){
    for (int i=0; i<c; i++){
        for (int j=r-1; j>=0; j--){
            temp[i][r-1-j] = num[j][i];
        }
    }
    int x = c;
    c = r;
    r = x;
    for (int i=0; i<r; i++){
        for (int j=0; j<c; j++){
            num[i][j] = temp[i][j];
        }            
    }
}

void one(){
    for (int i=0; i<c; i++){
        for (int j=0; j<r; j++){
            temp[j][i] = num[r-j-1][i];
        }
    }
    for (int i=0; i<r; i++){
        for (int j=0; j<c; j++){
            num[i][j] = temp[i][j];
        }            
    }
}

int main(){
    while (cin >> r >> c >> m){
        for (int i=0; i<r; i++){
            for (int j=0; j<c; j++){
                cin >> num[i][j];
            }
        }
        int mk;
        for (int i=0; i<m; i++){
            cin >> mk;
            if (!mk){
                zero();
            }
            else {
                one();
            }
        }
        cout << r << " " << c << '\n';
        for (int i=0; i<r; i++){
            for (int j=0; j<c; j++){
                if (!j){
                    cout << num[i][j];
                }
                else {
                    cout << " " << num[i][j];
                }
            }
            cout << '\n';
        }
    }
    return 0;
}

 
#32223: Re: 誰能幫我一下:(


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
b965. 2. 矩陣轉換 -- 2016年3月apcs | From: [118.160.177.110] | 發表日期 : 2022-09-23 00:07

#include

using namespace std;

int r, c, m, num[10][10], temp[10][10];

void zero(){
    for (int i=0; i
        for (int j=r-1; j>=0; j--){
            temp[i][r-1-j] = num[j][i];
        }
    }
    int x = c;
    c = r;
    r = x;
    for (int i=0; i
        for (int j=0; j
            num[i][j] = temp[i][j];
        }            
    }
}

void one(){
    for (int i=0; i
        for (int j=0; j
            temp[j][i] = num[r-j-1][i];
        }
    }
    for (int i=0; i
        for (int j=0; j
            num[i][j] = temp[i][j];
        }            
    }
}

int main(){
    while (cin >> r >> c >> m){
        for (int i=0; i
            for (int j=0; j
                cin >> num[i][j];
            }
        }
        int mk;
        for (int i=0; i
            cin >> mk;
            if (!mk){
                zero();
            }
            else {
                one();
            }
        }
        cout << r << " " << c << '\n';
        for (int i=0; i
            for (int j=0; j
                if (!j){
                    cout << num[i][j];
                }
                else {
                    cout << " " << num[i][j];
                }
            }
            cout << '\n';
        }
    }
    return 0;
}


輸入的是矩陣B,要算出矩陣A

 
#32317: Re: 誰能幫我一下:(


jason096727@gmail.com (Jason Ho)

學校 : 高雄市苓雅區福東國民小學
編號 : 189939
來源 : [150.116.71.76]
最後登入時間 :
2023-07-15 21:32:51
b965. 2. 矩陣轉換 -- 2016年3月apcs | From: [118.160.96.110] | 發表日期 : 2022-09-29 14:53

#include

using namespace std;

int r, c, m, num[10][10], temp[10][10];

void zero(){
    for (int i=0; i
        for (int j=r-1; j>=0; j--){
            temp[i][r-1-j] = num[j][i];
        }
    }
    int x = c;
    c = r;
    r = x;
    for (int i=0; i
        for (int j=0; j
            num[i][j] = temp[i][j];
        }            
    }
}

void one(){
    for (int i=0; i
        for (int j=0; j
            temp[j][i] = num[r-j-1][i];
        }
    }
    for (int i=0; i
        for (int j=0; j
            num[i][j] = temp[i][j];
        }            
    }
}

int main(){
    while (cin >> r >> c >> m){
        for (int i=0; i
            for (int j=0; j
                cin >> num[i][j];
            }
        }
        int mk;
        for (int i=0; i
            cin >> mk;
            if (!mk){
                zero();
            }
            else {
                one();
            }
        }
        cout << r << " " << c << '\n';
        for (int i=0; i
            for (int j=0; j
                if (!j){
                    cout << num[i][j];
                }
                else {
                    cout << " " << num[i][j];
                }
            }
            cout << '\n';
        }
    }
    return 0;
}


輸入的是矩陣B,要算出矩陣A

對不起我眼瞎:(

 
ZeroJudge Forum