思路 模拟每个面在前面的情况 固定前后时,以前后 为轴旋转
参考:https://blog.youkuaiyun.com/ramay7/article/details/50357366
https://blog.youkuaiyun.com/shiqi_614/article/details/7035558
AC代码:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N=20;
char str[N],str1[N],str2[N];
int dir[6][6]={ {0,1,2,3,4,5},{1,5,2,3,0,4},{2,1,5,0,4,3},{3,1,0,5,4,2},
{4,0,2,3,5,1},{5,4,2,3,1,0} };
bool fun()
{
char temp[N]={0};
for(int i=0;i<6;i++)
{
for(int j=0;j<6;j++)
{
temp[j]=str1[dir[i][j]];
}
for(int j=0;j<4;j++)
{
char c;
c=temp[1];
temp[1]=temp[2];
temp[2]=temp[4];
temp[4]=temp[3];
temp[3]=c;
if(strcmp(temp,str2)==0) return 1;
}
}
return 0;
}
int main()
{
while(scanf("%s",str)!=EOF)
{
for(int i=0;i<6;i++) {str1[i]=str[i];str2[i]=str[i+6];}
if(fun()) printf("TRUE\n");
else printf("FALSE\n");
}
return 0;
}