-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPREV-378.cpp
80 lines (71 loc) · 1.64 KB
/
PREV-378.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* hint:
* * C/C++ 用 3 Byte 表示中文字符
* * 未解决
*/
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#define MAXN 100
#define ANS_LEN 12
using namespace std;
char cube[2][2][2][ANS_LEN], operations[MAXN]="";
void init()
{
strcpy(cube[0][0][0], "篮橙白");
strcpy(cube[0][0][1], "红绿白");
strcpy(cube[0][1][0], "");
strcpy(cube[0][1][1], "篮红黄");
strcpy(cube[1][0][0], "绿白橙");
strcpy(cube[1][0][1], "绿红白");
strcpy(cube[1][1][0], "绿橙黄");
strcpy(cube[1][1][1], "绿黄红");
}
void x_op()
{
char s[ANS_LEN]="";
strcpy(s, cube[1][0][0]);
strcpy(cube[1][0][0], cube[1][1][0]);
strcpy(cube[1][1][0], cube[1][1][1]);
strcpy(cube[1][1][1], cube[1][0][1]);
strcpy(cube[1][0][1], s);
}
void y_op()
{
char s[ANS_LEN]="";
strcpy(s, cube[1][0][1]);
strcpy(cube[1][0][1], cube[1][1][1]);
strcpy(cube[1][1][1], cube[0][1][1]);
strcpy(cube[0][1][1], cube[0][0][1]);
strcpy(cube[0][0][1], s);
}
void z_op()
{
char s[ANS_LEN]="";
strcpy(s, cube[0][0][0]);
strcpy(cube[0][0][0], cube[1][0][0]);
strcpy(cube[1][0][0], cube[1][0][1]);
strcpy(cube[1][0][1], cube[0][0][1]);
strcpy(cube[0][0][1], s);
}
int transform(char *op)
{
int l = strlen(op);
for (int i = 0; i < l; i++)
if (op[i] == 'x') x_op();
else if (op[i] == 'y') y_op();
else if (op[i] == 'z') z_op();
else return 0;
return 1;
}
int main()
{
init();
cin.getline(operations, MAXN);
if(transform(operations))
printf("%s\n", cube[1][0][1]);
else
printf("Error\n");
return 0;
}