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.
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 the closest compass bearing according to the input.
Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 22, 2008
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3