/*
ID: modengd1
PROG: transform
LANG: C++
*/
#include <iostream>
#include <stdio.h>
using namespace std;
char input1[10][10],input2[10][10];
char temp[10][10];
int N;
bool isSame(char from[10][10],char to[10][10],int n)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(to[i][j]!=from[i][j])
return false;
}
}
return true;
}
void clockwize(char from[10][10],char to[10][10],int n)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
to[j][N-i-1]=from[i][j];
}
}
}
void reflaction(char from[10][10],char to[10][10],int n)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
to[i][n-j-1]=from[i][j];
}
}
}
void slove()
{
char temp1[10][10],temp2[10][10],temp3[10][10],temp4[10][10];
clockwize(input1,temp1,N);
if(isSame(input2,temp1,N))
{
cout<<1<<endl;
return;
}
clockwize(temp1,temp2,N);
if(isSame(input2,temp2,N))
{
cout<<2<<endl;
return;
}
clockwize(temp2,temp3,N);
if(isSame(input2,temp3,N))
{
cout<<3<<endl;
return;
}
reflaction(input1,temp4,N);
if(isSame(input2,temp4,N))
{
cout<<4<<endl;
return;
}
reflaction(input2,temp4,N);
if(isSame(temp1,temp4,N)||isSame(temp2,temp4,N)||isSame(temp3,temp4,N))
{
cout<<5<<endl;
return;
}
if(isSame(input1,input2,N))
{
cout<<6<<endl;
return;
}
cout<<7<<endl;
}
int main()
{
freopen("transform.in","r",stdin);
freopen("transform.out","w",stdout);
scanf("%d",&N);
getchar();
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
scanf("%c",&input1[i][j]);
}
getchar();
}
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
scanf("%c",&input2[i][j]);
}
getchar();
}
slove();
return 0;
}
原文:http://www.cnblogs.com/modengdubai/p/4760967.html