您的位置:首页 > 编程语言 > C语言/C++

Sicily 1128. DICE

2016-01-08 21:34 357 查看
Time Limit: 1 secs, Memory Limit: 32 MB

Description

Imagine looking at a six-sided die so two sides face east-west, two face north-south, and the last two sides face up-down. You could write down the number of dots on each side in the order: east, west, north, south, up, down.

Normal dice are labeled so that the sum of opposing sides sum to seven. This constraint is sufficient to reduce dice into two categories, “Left handed” and “Right handed.” Left handed dice can be oriented so that the east face is 1, the north face is 2, and the down face is 3. Right handed dice can be oriented so that the east face is 1, the north face is 2, and the up face is 3.

In this problem, given the face values of a sequence of dice, you are to determine the handedness of the dice.

Input

The input file will contain a sequence of one or more face descriptions of a die. These will be written as six digits (not separated by white space) on a single line. The numbers will represent (in order) the face values of the east, west, north, south, up, and down faces of the given die.

Output

Other than the standard leader and trailer, the output file simply has the word “left” or “right” for each dice in the input file.

Sample Input

162534

162543

526134

Sample Output

right

left

left

O(∩_∩)O~~ Just do it! 骰子游戏

#include <iostream>
#include <string>

using namespace std;

int main()
{
char Temp; string str;

while (cin >> str)
{
if (str[4] == '1' || str[5] == '1')
{   //// 绕Y轴逆时针翻转,确保‘1’位于东西南北之一
Temp = str[4];
str[4] = str[0];
str[0] = str[5];
str[5] = str[1];
str[1] = Temp;
}
while (str[0] != '1')
{   //// 绕Z轴逆时针旋转
Temp = str[0];
str[0] = str[2];
str[2] = str[1];
str[1] = str[3];
str[3] = Temp;
}
while (str[2] != '2')
{
//// 绕X轴逆时针旋转
Temp = str[2];
str[2] = str[5];
str[5] = str[3];
str[3] = str[4];
str[4] = Temp;
}
if (str[4] == '3')
cout << "right" << endl;
else
cout << "left" << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sicily c++