C + + Huawei OJ Second-order Rubik's Cube

Source: Internet
Author: User

"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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.