- import java.util.*;
- import static java.lang.System.*;
-
- public class main{
- public static void main(String[] args) {
- Scanner sc=new Scanner(System.in);
- while(sc.hasNextInt())
- {
- int num = sc.nextInt();
- if(num == 0)
- break;
- int top = 1, n = 2, w = 3, s = 5, e = 4;
- for(int i = 0; i < num; i++)
- {
- String cmd = sc.next();
- if(cmd.equals("north"))
- {
- n = top;
- top = s;
- s = 7 - n;
- }
- else if(cmd.equals("east"))
- {
- e = top;
- top = w;
- w = 7 - e;
- }
- else if(cmd.equals("south"))
- {
- s = top;
- top = n;
- n = 7 - s;
- }
- else if(cmd.equals("west"))
- {
- w = top;
- top = e;
- e = 7 - w;
- }
- }
- System.out.println(top);
- }
- }
- };
-
留言
張貼留言