[编程题]骰子翻转

/*
骰子:左1,右2,前3,后4,上5,下6
L:向左翻转
R:向右翻转
F:向前翻转
B:向后翻转
A:逆时针旋转90
C:顺时针旋转90


个面初始数字:123456
经过一系列翻转,求翻转后个面的数字

*/

#include 
#include 
#include 
using namespace std;


int main()
{
	string s = "123456";
	string input;
	getline(cin,input);
	int i = 0;
	while (i < input.size())
	{
		switch (input[i])
		{
			case 'L':
			{
				char temp1 = s[5];			
				char temp2 = s[1];
				char temp3 = s[4];
				char temp4 = s[0];
				s[5] = temp4;
				s[1] = temp1;			
				s[4] = temp2;
				s[0] = temp3;			
				break;
			}
			case 'R':
			{
				char temp1 = s[1];
				char temp2 = s[5];
				char temp3 = s[0];
				char temp4 = s[4];
				s[1] = temp4;
				s[5] = temp1;
				s[0] = temp2;
				s[4] = temp3;
				break;
			}
			case 'F':
			{
				char temp1 = s[2];
				char temp2 = s[5];
				char temp3 = s[3];
				char temp4 = s[4];
				s[2] = temp4;
				s[5] = temp1;
				s[3] = temp2;
				s[4] = temp3;
				break;
			}
			case 'B':
			{
				char temp1 = s[3];
				char temp2 = s[5];
				char temp3 = s[2];
				char temp4 = s[4];
				s[3] = temp4;
				s[5] = temp1;
				s[2] = temp2;
				s[4] = temp3;
				break;
			}
			case 'A':
			{
				char temp1 = s[1];
				char temp2 = s[3];
				char temp3 = s[0];
				char temp4 = s[2];
				s[1] = temp4;
				s[3] = temp1;
				s[0] = temp2;
				s[2] = temp3;
				break;
			}
			case 'C':
			{
				char temp1 = s[0];
				char temp2 = s[3];
				char temp3 = s[1];
				char temp4 = s[2];
				s[0] = temp4;
				s[3] = temp1;
				s[1] = temp2;
				s[2] = temp3;
				break;
			}

		}//end of switch
		i++;
	}//end of while
	cout << s << endl;
	system("pause");
	return 0;
}


你可能感兴趣的:(C++,小栗子)