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! 骰子游戏
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; }
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- 关于指针的一些事情
- c++ primer 第五版 笔记前言
- share_ptr的几个注意点
- Lua中调用C++函数示例
- Lua教程(一):在C++中嵌入Lua脚本
- Lua教程(二):C++和Lua相互传递数据示例
- C++联合体转换成C#结构的实现方法
- C++高级程序员成长之路
- C++编写简单的打靶游戏
- C++ 自定义控件的移植问题
- C++变位词问题分析
- C/C++数据对齐详细解析
- C++基于栈实现铁轨问题
- C++中引用的使用总结
- 使用Lua来扩展C++程序的方法
- C++中调用Lua函数实例
- Lua和C++的通信流程代码实例
- C与C++之间相互调用实例方法讲解
- 解析C++中派生的概念以及派生类成员的访问属性