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

hello12on Sep 11, 2017 - 8:58:56 pm UTCPEGPro2016on Dec 11, 2016 - 5:55:06 pm UTC ???jlsajfkon Dec 31, 2016 - 3:53:16 am UTC Re: ???N-45°

E-135°

S-135°

W-45°

Also the segment you picked for W happens to all be part of N

PEGPro2016on Jan 08, 2017 - 12:04:54 am UTC Re: ???jargonon Jan 08, 2017 - 6:12:33 pm UTC Re: ???Similarly, there should be 90 different values of N for which your code returns "S", but you accept 135 different values.

hello12on Sep 11, 2017 - 8:57:28 pm UTC Re: ???