Cube painting 

We have a machine for painting cubes. It is supplied withthree different colors: blue,red and green. Each face of the cube gets oneof these colors. The cube's faces arenumbered as in Figure 1.

Figure 1.

Since a cube has 6 faces, our machine canpaint a face-numbered cube in different ways. When ignoring the face-numbers,the number of different paintings ismuch less, because a cube can be rotated. See example below.We denote a painted cube by a string of 6 characters,where each character is ab, r,or g. The character ( ) fromthe left gives the color of facei. For example,Figure 2 is a picture of rbgggr and Figure 3corresponds torggbgr. Notice that bothcubes are painted in the same way: byrotating it around the vertical axis by 90 , theone changes into the other.

Input

The input of your program is a textfile thatends with the standard end-of-file marker.Each line is a string of 12 characters.The first 6 characters of this string are therepresentation of a painted cube, theremaining 6 characters give you the representationof another cube. Your program determines whetherthese two cubes are painted in thesame way, that is, whether by any combinationof rotations one can be turned into theother. (Reflections are not allowed.)

Output

The output is a file of boolean.For each line of input, output contains TRUE if thesecond half can be obtained from the firsthalf by rotation as describes above,FALSEotherwise.

Sample Input

rbgggrrggbgr
rrrbbbrrbbbr
rbgrbgrrrrrg

Sample Output

TRUE
FALSE
FALSE

题意: 一个如图所示的正方体, 每面标了数字以及印上了某字符

给出按原始顺序读取的(即按数字从小到大读)字符串以及我们需要的目标字符串

通过旋转正方体, 再读取这个正方体上的字符串 判断是否与我们需要的字符串顺序相同~

做法: 设定一份初始的顺序, 我这里是按某面朝上来份的, 数组为rot

而后, 每一种面朝上时, 围绕一根垂直顶面的轴, 都可以旋转四次~(在我的代码中是用for循环四次~)

每次旋转完要判断, 根据标记输出~TRUE or FALSE

AC代码:

#include<stdio.h>
#include<string.h> int rot[6][6] = {{1,2,3,4,5,6}, {2,6,3,4,1,5}, {6,5,3,4,2,1}, {5,1,3,4,6,2}, {3,1,2,5,6,4}, {4,6,2,5,1,3}}; int main() {
char oringe[7];
char tmp[7];
char change[7];
char str[13];
int pos;
while(gets(str) != NULL) { int mark = 0;
for(int i = 0; i < 6; i++)
oringe[i] = str[i];
oringe[6] = '\0'; pos = 0;
for(int i = 6; i < 12; i++)
change[pos++] = str[i];
change[pos] = '\0'; for(int i = 0; i < 6; i++) {
pos = 0;
for(int j = 0; j < 6; j++)
tmp[pos++] = oringe[rot[i][j]-1];
tmp[pos] = '\0';
char cht;
for(int j = 0; j < 4; j++) {
cht = tmp[1];
tmp[1] = tmp[2];
tmp[2] = tmp[4];
tmp[4] = tmp[3];
tmp[3] = cht;
if(strcmp(change, tmp) == 0) {
mark = 1;
break;
}
}
} if(mark)
printf("TRUE\n");
else
printf("FALSE\n");
}
return 0;
}

UVA 253 (13.08.06)的更多相关文章

  1. UVA 573 (13.08.06)

     The Snail  A snail is at the bottom of a 6-foot well and wants to climb to the top.The snail can cl ...

  2. UVA 10499 (13.08.06)

    Problem H The Land of Justice Input: standard input Output: standard output Time Limit: 4 seconds In ...

  3. UVA 10025 (13.08.06)

     The ? 1 ? 2 ? ... ? n = k problem  Theproblem Given the following formula, one can set operators '+ ...

  4. UVA 10790 (13.08.06)

     How Many Points of Intersection?  We have two rows. There are a dots on the toprow andb dots on the ...

  5. UVA 10194 (13.08.05)

    :W Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (ameri ...

  6. UVA 465 (13.08.02)

     Overflow  Write a program that reads an expression consisting of twonon-negative integer and an ope ...

  7. UVA 10494 (13.08.02)

    点此连接到UVA10494 思路: 采取一种, 边取余边取整的方法, 让这题变的简单许多~ AC代码: #include<stdio.h> #include<string.h> ...

  8. UVA 424 (13.08.02)

     Integer Inquiry  One of the first users of BIT's new supercomputer was Chip Diller. Heextended his ...

  9. UVA 10106 (13.08.02)

     Product  The Problem The problem is to multiply two integers X, Y. (0<=X,Y<10250) The Input T ...

随机推荐

  1. win7 下配置resin的一些tip

    一.如何查看jdk安装目录: 通过不同方法搜索javac看看, javac.exe 是java的编译器: 可用的搜索方法: 1.cmd 控制台:  where javac 2.开始菜单的搜索: 一直到 ...

  2. loadrunner中lr_log_message和lr_output_message 的区别

    LoadRunner中lr_output_message和lr_log_message(1)在vgen中,我们必须写输出函数输出信息,将我们所想要了解的信息用函数输出,主要有这么几个函数输出信息: l ...

  3. python2.7系列安装失败的办法

    在windows系统上安装python时出现"there is a problem with your Windows installer package. A program run as ...

  4. SQL求 交集 并集 差集

    故事是这样的….. 故事情节: 表 tb_test 有两列, colA , colB; 求 colA , colB 的并交差集… -- 计算并集 SELECT DISTINCT colB FROM t ...

  5. ubuntu下Qt cannot find -lGL错误的解决方法 (转载)

    在ubuntu下使用Qt 编译时候遇上了cannot find -lGL错误,使用命令 sudo apt-get install libqt4-dev或者sudo apt-get install li ...

  6. 30+学习Web设计和开发的优质新鲜资源

    今天我们整理了一些最新的Web设计和开发的资源,这些资源都来自国外的流行站点,不过大家应该不会陌生,放在这里供大家收藏,在需要的时候方便翻阅和学习! 原文地址:http://www.goodfav.c ...

  7. Eclipse下建立geoserver源码工程

    摘要:本文详细阐述,如何基于geoserver源码构建eclipse工程文件,操作过程中除用到jdk.eclipse以外,还有git和maven,操作系统为windows8. 1安装Git 从(htt ...

  8. Hadoop学习笔记(7) ——高级编程

    Hadoop学习笔记(7) ——高级编程 从前面的学习中,我们了解到了MapReduce整个过程需要经过以下几个步骤: 1.输入(input):将输入数据分成一个个split,并将split进一步拆成 ...

  9. Google Test资料

    Google Test资料 玩转Google开源C++单元测试框架Google Test系列(gtest)(总) gtest.h file not found googletest xcode 7.0 ...

  10. 谈FTP服务器攻击技术及其展望 (修改中)

      欢迎大家给我投票: http://2010blog.51cto.com/350944 请看下篇:谈FTP服务器攻击技术及其展望 (下)              全文完http://chengua ...