解题思路: 枚举,
六面体 ,上方标为1的一面,正下方为6,此时有4种情况,即是123456,135246,154326,142536共4种情况;上方可有1,2,3,4,5,6共6种情况,即共24种情况;由1为上方的那种情况,可得到对应关系如下
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=20;
int d[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} };
char str[N],str1[N],str2[N];
bool time(){
char temp[N]={0};
for(int i=0;i<6;i++){
for(int j=0;j<6;j++){
temp[j]=str1[d[i][j]];
}
for(int k=0;k<4;k++){
char t=temp[1];
temp[1]=temp[2];
temp[2]=temp[4];
temp[4]=temp[3];
temp[3]=t;
if(strcmp(temp,str2)==0) return true;
}
}
return false;
}
int main(){
while(scanf("%s",str)!=EOF){
for(int i=0;i<6;i++){
str1[i]=str[i];
str2[i]=str[i+6];
}
if(time()) puts("TRUE");
else puts("FALSE");
}
return 0;
}