#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;
//1171
int mtr[6][6];
void change(int a,int b,int x,int y){
int tmp[6][6];
for(int i=1;i<=5;i++)
for(int j=1;j<=5;j++)
tmp[i][j]=mtr[i][j];
if(a==1){
if(b==2){//顺时针反转四个数
mtr[x][y]=tmp[x+1][y];
mtr[x][y+1]=tmp[x][y];
mtr[x+1][y]=tmp[x+1][y+1];
mtr[x+1][y+1]=tmp[x][y+1];
}
else if(b==3){//顺时针九个数
mtr[x][y]=tmp[x+2][y];
mtr[x][y+1]=tmp[x+1][y];
mtr[x][y+2]=tmp[x][y];
mtr[x+1][y]=tmp[x+2][y+1];
mtr[x+1][y+1]=tmp[x+1][y+1];
mtr[x+1][y+2]=tmp[x][y+1];
mtr[x+2][y]=tmp[x+2][y+2];
mtr[x+2][y+1]=tmp[x+1][y+2];
mtr[x+2][y+2]=tmp[x][y+2];
}
}
else if(a==2){
if(b==2){//逆时针四个数
mtr[x][y]=tmp[x][y+1];
mtr[x][y+1]=tmp[x+1][y+1];
mtr[x+1][y]=tmp[x][y];
mtr[x+1][y+1]=tmp[x+1][y];
}
else if(b==3){//逆时针九个数
mtr[x][y]=tmp[x][y+2];
mtr[x][y+1]=tmp[x+1][y+2];
mtr[x][y+2]=tmp[x+2][y+2];
mtr[x+1][y]=tmp[x][y+1];
mtr[x+1][y+1]=tmp[x+1][y+1];
mtr[x+1][y+2]=tmp[x+2][y+1];
mtr[x+2][y]=tmp[x][y];
mtr[x+2][y+1]=tmp[x+1][y];
mtr[x+2][y+2]=tmp[x+2][y];
}
}
}
int main(){
//freopen("input.txt","r",stdin);
while(scanf("%d%d%d%d%d",&mtr[1][1],&mtr[1][2],&mtr[1][3],&mtr[1][4],&mtr[1][5])!=EOF){
for(int i=2;i<=5;i++)
for(int j=1;j<=5;j++)
scanf("%d",&mtr[i][j]);
int a,b,x,y;
scanf("%d%d%d%d",&a,&b,&x,&y);
change(a,b,x,y);
for(int i=1;i<=5;i++){
for(int j=1;j<=5;j++){
if(j==1) cout<<mtr[i][j];
else cout<<" "<<mtr[i][j];
}
cout<<endl;
}
}
return 0;
}
/**************************************************************
Problem: 1171
User: cust123
Language: C++
Result: Accepted
Time:0 ms
Memory:1520 kb
****************************************************************/
题目1171:C翻转
最新推荐文章于 2023-03-12 03:30:00 发布