BlueBook

p108ex8 - Direction

Given an integer N (0 ≤ N < 360), print out the closest compass bearing to that integer if N is the bearing in degrees. If there is a tie, print the "smaller" of the two possible outputs.

The bearings arranged in increasing order of "size" are: N, E, S, W. This means choose N over E if the input is 45, and N over W when the input is 315.

Input

The input consists of an integer T (1 ≤ T ≤ 1000), denoting the number of test cases and then each line following consists of one integer N.

Output

Output the closest compass bearing according to the input.

Sample Input

2
45
180

Sample Output

N
S

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 22, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

jkjk lol my spelling is excellent

What am I doing wrong???? Thanks!

Each bearing should have 90° attached to it, while your code has:
N-45°
E-135°
S-135°
W-45°
Also the segment you picked for W happens to all be part of N

I still don't understand. What does "Each bearing should have 90 degrees attached to it" mean?

There should be 90 different values of N for which your code returns "W", but you only accept 45 such values.

Similarly, there should be 90 different values of N for which your code returns "S", but you accept 135 different values.

veri gud! serry mi sppll in is veri bad