码迷,mamicode.com
首页 > 其他好文 > 详细

uva 253 - Cube painting

时间:2014-08-29 18:36:38      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:style   http   os   io   ar   for   代码   sp   amp   

题目

    链接

思路

    选择立方体一面为参照面有6中可能,直接硬编码。

     每种参照情况下,选择侧面能构建再4种情况。

代码

#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();

int main(){    
    while(scanf("%s",str)!=EOF) {        
        for(int i=0;i<6;i++) str1[i]=str[i];        
        for(int i=0;i<6;i++) str2[i]=str[i+6];        
        if(fun()) puts("TRUE");        
        else puts("FALSE");    
    }    
return 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 cha;            
            cha=temp[1];            
            temp[1]=temp[2];            
            temp[2]=temp[4];            
            temp[4]=temp[3];            
            temp[3]=cha;            
            if(strcmp(temp,str2)==0) 
                return true;        
        }    
    }    
    return false;
}


uva 253 - Cube painting

标签:style   http   os   io   ar   for   代码   sp   amp   

原文地址:http://my.oschina.net/u/572632/blog/308142

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!