#36650: 找了好久還是看不到問題

#### p0966543710@gmail.com (Nicole Yang)

School : No School
ID : 238960
2024-07-19 13:49:48
b965. 2. 矩陣轉換 -- | From: [120.117.72.138] | Post Date : 2023-07-31 12:36

(完整程式碼如下 抱歉有點亂)
#include <iostream>
#include <vector>
using namespace std;

void rotate(int R, int C, vector<vector<int>>& B,vector<vector<int>>& B1){
for(int i = 0; i < R; i++){
for(int j = 0; j < C; j++){
B1[C-1-j][i] = B[i][j];
}
}
}
void flip(int R, int C, vector<vector<int>>& B){
for(int i = 0; i < R/2; i++){
for(int j =  0; j < C; j++){
int temp = B[i][j];
B[i][j] = B[R-1-i][j];
B[R-1-i][j] = temp;
}
}
}
void cin_B(int R, int C, vector<vector<int>>& B){
for(int i = 0; i < R;i++){
for(int j = 0; j < C; j++){
cin >> B[i][j];
}
}
}
void print_B(int R,int C,vector<vector<int>>& B){
cout << R <<" "<< C << endl;
for(int i = 0; i < R;i++){
for(int j = 0; j < C; j++){
cout << B[i][j];
if(j!=C-1){
cout<<" ";
}
}
cout << endl;
}
}
int main(){
vector<vector<int>> B(11,vector<int>(11,0));
vector<vector<int>> B1(11,vector<int>(11,0));
int R,C,M,m,count=0;
while(cin >> R >> C >> M){
if (R == 0 && C == 0) {
break;
}
cin_B(R,C,B);
for(int i = 0; i < M; i++){
cin >> m;
if(m==0){
if(count==0){
rotate(R,C,B,B1);
count = 1;
}
else{
rotate(C,R,B1,B);
count = 0;
}
}
if(m==1){
if(count==0){
flip(R,C,B);
}
else{
flip(C,R,B1);
}
}
}
if(count==0){
print_B(R,C,B);
}
else{
print_B(C,R,B1);
}
}
return 0;
}

#36705: Re: 找了好久還是看不到問題

#### cges30901 (cges30901)

School : No School
ID : 30877
2024-07-17 21:28:57
b965. 2. 矩陣轉換 -- | From: [118.160.198.38] | Post Date : 2023-08-03 21:06

#36711: Re: 找了好久還是看不到問題

#### p0966543710@gmail.com (Nicole Yang)

School : No School
ID : 238960
2024-07-19 13:49:48
b965. 2. 矩陣轉換 -- | From: [111.254.161.183] | Post Date : 2023-08-03 22:31

#36712: Re: 找了好久還是看不到問題

#### p0966543710@gmail.com (Nicole Yang)

School : No School
ID : 238960