"Title description"
Second order Rubik's Cube
Rubik's Cube can be used for its 6 free rotation of the face. Let's operate a 2 - order cube (1 ) for the sake of convenience, we have set up a coordinate system for it.
The initial state of each polygon is as follows:
X-axis positive: Green
X- axis reverse: Blue
y Axial direction: Red
y axis reverse: orange
Z Axial direction: white
Z axis reverse: yellow
Suppose we stipulate that the Rubik's Cube can only be 3 type of operation. Marked as:
x indicates a clockwise rotation on the x - axis.
y indicates a clockwise rotation on the y - axis.
z indicates clockwise rotation on z-axis
the effect after the basic rotation 2,3,4 is shown.
XYZ indicates sequential execution x, Y, Z 3 an operation
Program Input:
Gets a string from the standard input that represents the sequence of operations.
Program output: The one nearest to our little box 3 the color of the face.
The order is: x Face, y Face, Z face.
For example: In the initial state, the output should be:
Green Red and white
In the initial state, if the user enters:
X
The output should be:
Green and white Orange
In the initial state, if the user enters:
Zyx
The output should be:
Red, white and green
"Realization of thought"
Custom functions: Switch. Case (X Y Z), the string swap can be implemented.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
C + + Huawei OJ Second-order Rubik's Cube