Niu Niu went to Teacher Benben's house to make up lessons, and when he went out, he faced north, but now he is lost. Although he has a map in his hand, he needs to know which direction he is facing, please help him.
Enter description:
Each input contains a test case.
The first line of each test case contains a positive integer that represents the number of turns N (N<=1000).
The next line contains a string of length N consisting of L and R, where L means turn left and R means turn right.
Output description:
Output the direction that Niu Niu was facing last, N for North, S for South, E for East, and W for West.
Input example 1:
3 LRR
Output example 1:
E
======================================
#include <iostream> using namespace std; intmain() { int n; cin>>n; char dir[5]="NESW"; int now=0; for(int i=0;i<n;i++) { char step; cin>>step; if(step=='L') { now = (now + 4 - 1) % 4; } else { now = (now + 1) % 4; } } return 0; }