AcWing 3535. C翻转
原题链接
简单
作者:
云里雾里
,
2025-03-24 22:37:38
·山东
,
所有人可见
,
阅读 3
别说了 暴力美学
代码
#include<iostream>
using namespace std;
int pre[6][6];
int pro[6][6];
int main(){
for(int i=1;i<=5;i++){
for(int j=1;j<=5;j++){
cin>>pre[i][j];
}
}
int a,b,c,d;
cin>>a>>b>>c>>d;
int n=b;
int temp[5][5];
int temp2[5][5];
if(a==1)
{
if(b == 2)
{
for(int i = 1; i <= 2; i++)
for(int j = 1; j <= 2; j++)
{
temp[i][j] = pre[i + c - 1][j + d - 1];
}
temp2[1][2] = temp[1][1];
temp2[2][2] = temp[1][2];
temp2[2][1] = temp[2][2];
temp2[1][1] = temp[2][1];
for(int i = 1; i <= 2; i++)
for(int j = 1; j <= 2; j++)
{
pre[i + c - 1][j + d - 1] = temp2[i][j];
}
}
else if(b == 3)
{
for(int i = 1; i <= 3; i++)
for(int j = 1; j <= 3; j++)
{
temp[i][j] = pre[i + c - 1][j + d - 1];
}
temp2[1][1] = temp[3][1];
temp2[1][3] = temp[1][1];
temp2[3][3] = temp[1][3];
temp2[3][1] = temp[3][3];
temp2[2][2] = temp[2][2];
temp2[1][2] = temp[2][1];
temp2[2][3] = temp[1][2];
temp2[3][2] = temp[2][3];
temp2[2][1] = temp[3][2];
for(int i = 1; i <= 3; i++)
for(int j = 1; j <= 3; j++)
{
pre[i + c - 1][j + d - 1] = temp2[i][j];
}
}
}
else if(a==2)
{
if(b == 2)
{
for(int i = 1; i <= 2; i++)
for(int j = 1; j <= 2; j++)
{
temp[i][j] = pre[i + c - 1][j + d - 1];
}
temp2[1][1] = temp[1][2];
temp2[1][2] = temp[2][2];
temp2[2][2] = temp[2][1];
temp2[2][1] = temp[1][1];
for(int i = 1; i <= 2; i++)
for(int j = 1; j <= 2; j++)
{
pre[i + c - 1][j + d - 1] = temp2[i][j];
}
}
else if(b == 3)
{
for(int i = 1; i <= 3; i++)
for(int j = 1; j <= 3; j++)
{
temp[i][j] = pre[i + c - 1][j + d - 1];
}
temp2[3][1] = temp[1][1];
temp2[1][1] = temp[1][3];
temp2[1][3] = temp[3][3];
temp2[3][3] = temp[3][1];
temp2[2][2] = temp[2][2];
temp2[2][1] = temp[1][2];
temp2[1][2] = temp[2][3];
temp2[2][3] = temp[3][2];
temp2[3][2] = temp[2][1];
for(int i = 1; i <= 3; i++)
for(int j = 1; j <= 3; j++)
{
pre[i + c - 1][j + d - 1] = temp2[i][j];
}
}
}
for(int i=1;i<=5;i++){
for(int j=1;j<=5;j++){
cout<<pre[i][j]<<" ";
}
cout<<endl;
}
return 0;
}