## 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.

`2`
`45`
`180`

### Sample Output

`N`
`S`

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

• (0/0)
N-45°
E-135°
S-135°
W-45°
???

• (0/0)
You need to use 1 more for loop and an array because then you can print everything at the bottom.

• (0/0)
You need to use a array and use more for loops

• (0/0)
why?
It seems to work fine with the sample test cases i give it!

• (1/0)
What is wrong with my code, I don't understand what I am doing wrong!

• (0/1)
jkjk lol my spelling is excellent

• (0/0)
What am I doing wrong???? Thanks!

• (3/0)
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

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

• (3/0)
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.

• (0/2)
veri gud! serry mi sppll in is veri bad