#32518: 有人可以幫我看看哪裡不對嗎？

#### chiyuhsuan (暄)

School : No School
ID : 193909
IP address : [114.140.65.13]
2023-01-07 13:52:10
b965. 第 2 題 矩陣轉換 -- | From: [211.23.3.222] | Post Date : 2022-10-18 12:55

#include <iostream>

using namespace std;

int main()

{

int r, c, m, s[11][11], mm[11], h[11][11], t, i, j, k, l=0;

while(cin >> r >> c >> m){

for(i=1; i<=r; i++){

for(j=1; j<=c; j++)

cin >> s[i][j];

}

for (i=1; i<=m; i++)

cin >> mm[i];

for (k=1, t=0; k<=m; k++){

if (mm[k]==1){

for(i=1; i<=r/2; i++){

for(j=1; j<=c; j++){

t=s[i][j];

s[i][j]=s[r-i+1][j];

s[r-i+1][j]=t;

}

}

}

else if(mm[k]==0){

for(i=1; i<=c; i++){

for(j=1; j<=r; j++){

h[i][j]=s[r-j+1][i];

}

}

for(i=1; i<=c; i++){

for(j=1; j<=r; j++){

s[i][j]=h[i][j];

}

}

l=r;

r=c;

c=l;

}

}

cout << r << " " << c << endl;

for (i=1; i<=r; i++){

for (j=1; j<c; j++)

cout << s[i][j] << " ";

cout << s[i][c] << endl;

}

}

return 0;

}

#32584: Re: 有人可以幫我看看哪裡不對嗎？

#### cges30901 (cges30901)

School : No School
ID : 30877
IP address : [101.136.114.122]
2023-12-09 16:16:00
b965. 第 2 題 矩陣轉換 -- | From: [27.53.233.124] | Post Date : 2022-10-22 19:07

#include

using namespace std;

int main()

{

int r, c, m, s[11][11], mm[11], h[11][11], t, i, j, k, l=0;

while(cin >> r >> c >> m){

for(i=1; i<=r; i++){

for(j=1; j<=c; j++)

cin >> s[i][j];

}

for (i=1; i<=m; i++)

cin >> mm[i];

for (k=1, t=0; k<=m; k++){

if (mm[k]==1){

for(i=1; i<=r/2; i++){

for(j=1; j<=c; j++){

t=s[i][j];

s[i][j]=s[r-i+1][j];

s[r-i+1][j]=t;

}

}

}

else if(mm[k]==0){

for(i=1; i<=c; i++){

for(j=1; j<=r; j++){

h[i][j]=s[r-j+1][i];

}

}

for(i=1; i<=c; i++){

for(j=1; j<=r; j++){

s[i][j]=h[i][j];

}

}

l=r;

r=c;

c=l;

}

}

cout << r << " " << c << endl;

for (i=1; i<=r; i++){

for (j=1; j

cout << s[i][j] << " ";

cout << s[i][c] << endl;

}

}

return 0;

}

#32597: Re: 有人可以幫我看看哪裡不對嗎？

#### chiyuhsuan (暄)

School : No School
ID : 193909
IP address : [114.140.65.13]
2023-01-07 13:52:10
b965. 第 2 題 矩陣轉換 -- | From: [125.230.155.22] | Post Date : 2022-10-23 11:16

#include

using namespace std;

int main()

{

int r, c, m, s[11][11], mm[11], h[11][11], t, i, j, k, l=0;

while(cin >> r >> c >> m){

for(i=1; i<=r; i++){

for(j=1; j<=c; j++)

cin >> s[i][j];

}

for (i=1; i<=m; i++)

cin >> mm[i];

for (k=1, t=0; k<=m; k++){

if (mm[k]==1){

for(i=1; i<=r/2; i++){

for(j=1; j<=c; j++){

t=s[i][j];

s[i][j]=s[r-i+1][j];

s[r-i+1][j]=t;

}

}

}

else if(mm[k]==0){

for(i=1; i<=c; i++){

for(j=1; j<=r; j++){

h[i][j]=s[r-j+1][i];

}

}

for(i=1; i<=c; i++){

for(j=1; j<=r; j++){

s[i][j]=h[i][j];

}

}

l=r;

r=c;

c=l;

}

}

cout << r << " " << c << endl;

for (i=1; i<=r; i++){

for (j=1; j

cout << s[i][j] << " ";

cout << s[i][c] << endl;

}

}

return 0;

}

ZeroJudge Forum