uva253 CubePainting

简单题,总共24中旋转方法,一一列举。

#include<iostream>
#include<cstring>

using namespace std;

int tables[24][6] = {    {1,2,3,4,5,6},{1,3,5,2,4,6},{1,4,2,5,3,6},{1,5,4,3,2,6},
                        {2,1,4,3,6,5},{2,3,1,6,4,5},{2,4,6,1,3,5},{2,6,3,4,1,5},
                        {3,1,2,5,6,4},{3,2,6,1,5,4},{3,5,1,6,2,4},{3,6,5,2,1,4},
                        {4,1,5,2,6,3},{4,2,1,6,5,3},{4,5,6,1,2,3},{4,6,2,5,1,3},
                        {5,1,3,4,6,2},{5,3,6,1,4,2},{5,4,1,6,3,2},{5,6,4,3,1,2},
                        {6,2,4,3,5,1},{6,3,2,5,4,1},{6,4,5,2,3,1},{6,5,3,4,2,1} };

int main()
{
    char cube[10], rcube[10], str[20];
    while (cin >> str) {
        int i;
        memset(cube, 0, sizeof(cube));
        memset(rcube, 0, sizeof(rcube));
        for (i = 0; i < 6; i++) {
            cube[i] = str[i];
            rcube[i] = str[i + 6];
        }
        int flag = 0;
        for(i = 0;i < 24; i++){
            int temp = 1;
            for(int j=0;j<6;j++){
                if(cube[tables[i][j]-1]!=rcube[j]){
                    temp=0;
                    break;
                }
            }
            if(temp==1){
                flag=1;
                break;
            }
        }
        if(flag)cout<<"TRUE"<<endl;
        else cout<<"FALSE"<<endl;
    }

    return 0;
}

猜你喜欢

转载自www.cnblogs.com/ArvinShaffer/p/9032084.html