#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;
}
#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
#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
對不起我眼瞎:(