uva 253 Cube painting
来源:互联网 发布:cs拍照软件下载 编辑:程序博客网 时间:2024/04/19 21:10
一道简单题,把所有情况列举出来进行对比就行了,原来的顶面可能在旋转后出现在六个面任意一个,当顶面固定的时候,以顶面和底面的连线为轴旋转,会出现4中组合,把所有情况都考虑到就行了,我用的是暴力解法。
#include <stdio.h>#include <string.h>char color1[8];char color2[8];void func(){char temp[8];int i;bool f;char t;//分别对比6种情况f = false;temp[7] = '\0';//不旋转strcpy(temp+1, color1+1);if(temp[1]==color2[1] && temp[6]==color2[6]){if(!strcmp(temp+1,color2+1)){f = true; goto end;}for(i=1; i<=3; i++){t=temp[3]; temp[3]=temp[2]; temp[2]=temp[4]; temp[4]=temp[5]; temp[5]=t;if(!strcmp(temp+1,color2+1)){f = true; goto end;}}}//向左旋转一次temp[1] = color1[4];temp[2] = color1[2];temp[3] = color1[1];temp[4] = color1[6];temp[5] = color1[5];temp[6] = color1[3];if(temp[1]==color2[1] && temp[6]==color2[6]){if(!strcmp(temp+1,color2+1)){f = true; goto end;}for(i=1; i<=3; i++){t=temp[3]; temp[3]=temp[2]; temp[2]=temp[4]; temp[4]=temp[5]; temp[5]=t;if(!strcmp(temp+1,color2+1)){f = true; goto end;}}}//向左旋转两次temp[1] = color1[6];temp[2] = color1[2];temp[3] = color1[4];temp[4] = color1[3];temp[5] = color1[5];temp[6] = color1[1];if(temp[1]==color2[1] && temp[6]==color2[6]){if(!strcmp(temp+1,color2+1)){f = true; goto end;}for(i=1; i<=3; i++){t=temp[3]; temp[3]=temp[2]; temp[2]=temp[4]; temp[4]=temp[5]; temp[5]=t;if(!strcmp(temp+1,color2+1)){f = true; goto end;}}}//向右旋转一次temp[1] = color1[3];temp[2] = color1[2];temp[3] = color1[6];temp[4] = color1[1];temp[5] = color1[5];temp[6] = color1[4];if(temp[1]==color2[1] && temp[6]==color2[6]){if(!strcmp(temp+1,color2+1)){f = true; goto end;}for(i=1; i<=3; i++){t=temp[3]; temp[3]=temp[2]; temp[2]=temp[4]; temp[4]=temp[5]; temp[5]=t;if(!strcmp(temp+1,color2+1)){f = true; goto end;}}}//向前旋转一次temp[1] = color1[5];temp[2] = color1[1];temp[3] = color1[3];temp[4] = color1[4];temp[5] = color1[6];temp[6] = color1[2];if(temp[1]==color2[1] && temp[6]==color2[6]){if(!strcmp(temp+1,color2+1)){f = true; goto end;}for(i=1; i<=3; i++){t=temp[3]; temp[3]=temp[2]; temp[2]=temp[4]; temp[4]=temp[5]; temp[5]=t;if(!strcmp(temp+1,color2+1)){f = true; goto end;}}}//向后旋转一次temp[1] = color1[2];temp[2] = color1[6];temp[3] = color1[3];temp[4] = color1[4];temp[5] = color1[1];temp[6] = color1[5];if(temp[1]==color2[1] && temp[6]==color2[6]){if(!strcmp(temp+1,color2+1)){f = true; goto end;}for(i=1; i<=3; i++){t=temp[3]; temp[3]=temp[2]; temp[2]=temp[4]; temp[4]=temp[5]; temp[5]=t;if(!strcmp(temp+1,color2+1)){f = true; goto end;}}}end: if(f)printf("TRUE\n");elseprintf("FALSE\n");}int main(void){char buffer[20];while(gets(buffer)){memcpy(color1+1, buffer, 6);color1[7] = '\0';memcpy(color2+1, buffer+6, 6);color2[7] = '\0';func();}}
- UVa 253 - Cube painting
- Uva 253 - Cube painting
- Uva 253 Cube Painting
- uva 253 Cube painting
- uva 253 - Cube painting
- UVa 253 - Cube painting
- UVA 253 - Cube painting
- UVA 253 - Cube painting
- UVA 253 Cube painting
- UVa 253: Cube painting
- uva 253 - Cube painting
- uva 253 Cube painting
- UVA 253 Cube painting
- 253 - Cube painting UVA
- UVa 253 Cube painting
- UVA-253-Cube painting
- UVa 253 - Cube painting
- UVA 253 Cube painting
- Cocos2D-x中关于do{}while(0)和CC_BREAK_IF的用法
- js操作表格
- 利用业务中的主动和被动巧妙的驱动用户遵守规则
- 拉丁方阵问题。(数组版)
- 微信在android平台上开发的注意事项(以官方提供的demo为例):
- uva 253 Cube painting
- 微信公众平台开发
- NSDateFormatter格式详细列表一览
- 常用代码备忘录-DbUtil.java
- Ext3.3的Record和Store
- 形参与实参, 值传递与引用传递, ref参数与out参数
- Android 系统属性SystemProperty分析
- 关于将MyBatis中的ORDER BY语句抽象到base中的考虑
- java assert