-
Notifications
You must be signed in to change notification settings - Fork 0
/
10409.CPP
71 lines (57 loc) · 890 Bytes
/
10409.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
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
void swap(int &a,int &b)
{
int c;
c=a;
a=b;
b=c;
}
void north(int *p)
{
swap(p[0],p[2]);
swap(p[2],p[5]);
swap(p[2],p[4]);
}
void south(int *p)
{
swap(p[0],p[5]);
swap(p[5],p[2]);
swap(p[4],p[5]);
}
void west(int *p)
{
swap(p[1],p[2]);
swap(p[2],p[3]);
swap(p[3],p[5]);
}
void east(int *p)
{
swap(p[1],p[2]);
swap(p[3],p[5]);
swap(p[1],p[3]);
}
main()
{
char s[6];
int *p;
int N;
int i;
while (cin>>N && N)
{
p=new int[6];
p[0]=2,p[1]=3,p[2]=1,p[3]=4,p[4]=5,p[5]=6;
for (i=1;i<=N;i++)
{
cin>>s;
if (strcmp(s,"north")==0) north(p);
else if (strcmp(s,"south")==0) south(p);
else if (strcmp(s,"west")==0) west(p);
else if (strcmp(s,"east")==0) east(p);
}
cout<<p[2]<<endl;
}
return 0;
}