#30845: WA: 我不知我哪做錯了QAQ


john01152004@gmail.com (鍾承恩)

學校 : 不指定學校
編號 : 147670
來源 : [101.9.136.120]
最後登入時間 :
2022-06-17 16:59:39
b266. 矩陣翻轉 -- 2016 APCS 實作題第二題 | From: [101.9.137.182] | 發表日期 : 2022-06-15 21:10

我是使用C++寫的,程式在自己的電腦跑 輸出都是正確的,可是到ZeroJudge 上就只出現WA ,我不明白是怎麼回事,有好心人解惑嗎 謝謝

 

#include <iostream>
using namespace std;
int arr[10][10], temp[10][10];

void flip(int,int);
void turn(int,int);

int main(){
int row, column, someManipulations;
cin >> row >> column >> someManipulations;

int manipulateArr[someManipulations];     //存放操作指令的陣列
for (int i=0; i<row; i++)
for(int j=0; j<column; j++)
cin >> arr[i][j];

for (int i=0; i<someManipulations; i++)
cin >> manipulateArr[i];

for (int i=someManipulations-1; i>=0; i--){
if (manipulateArr[i] == 0){
// turn
turn(row, column);     //  逆時針90度旋轉
int temp = row;
row = column;
column = temp;
}
else {
flip(row,column);       // 翻轉
}
}

cout << row << " " << column << endl;
for (int i=0; i<row; i++){
cout << arr[i][0];
for (int j=1; j<column; j++)
cout << " " << arr[i][j];
cout << endl;
}
 

}

void flip(int row, int column){
for (int i=0; i<row; i++)
for (int j=0; j<column; j++)
temp[i][j] = arr[i][j];

for (int i=0; i<row; i++)
for (int j=0; j<column; j++)
arr[row-i-1][j] = temp[i][j];
}

void turn(int row, int column){
for (int i=0; i<row; i++)
for (int j=0; j<column; j++){
temp[column-1-j][i] = arr[i][j];
}
for (int i=0; i<column; i++)
for (int j=0; j<row; j++)
arr[i][j] = temp[i][j];
}



 
#31059: Re: WA: 我不知我哪做錯了QAQ


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
b266. 矩陣翻轉 -- 2016 APCS 實作題第二題 | From: [101.136.50.122] | 發表日期 : 2022-07-09 13:23

我是使用C++寫的,程式在自己的電腦跑 輸出都是正確的,可是到ZeroJudge 上就只出現WA ,我不明白是怎麼回事,有好心人解惑嗎 謝謝

 

#include
using namespace std;
int arr[10][10], temp[10][10];

void flip(int,int);
void turn(int,int);

int main(){
int row, column, someManipulations;
cin >> row >> column >> someManipulations;

int manipulateArr[someManipulations];     //存放操作指令的陣列
for (int i=0; i
for(int j=0; j
cin >> arr[i][j];

for (int i=0; i
cin >> manipulateArr[i];

for (int i=someManipulations-1; i>=0; i--){
if (manipulateArr[i] == 0){
// turn
turn(row, column);     //  逆時針90度旋轉
int temp = row;
row = column;
column = temp;
}
else {
flip(row,column);       // 翻轉
}
}

cout << row << " " << column << endl;
for (int i=0; i
cout << arr[i][0];
for (int j=1; j
cout << " " << arr[i][j];
cout << endl;
}
 

}

void flip(int row, int column){
for (int i=0; i
for (int j=0; j
temp[i][j] = arr[i][j];

for (int i=0; i
for (int j=0; j
arr[row-i-1][j] = temp[i][j];
}

void turn(int row, int column){
for (int i=0; i
for (int j=0; j
temp[column-1-j][i] = arr[i][j];
}
for (int i=0; i
for (int j=0; j
arr[i][j] = temp[i][j];
}




我用你的程式碼送出是AC

 
ZeroJudge Forum