Compass Conundrum
Your child is going off onto a hike, but you are worried that they are going to get lost, starve, and die. Even worse is that they do not understand how compass bearings work. You decide to create a program to convert from compass bearings to true bearings in order to help.
A compass bearing takes the form AdB, where Ais one of N, S, and B is one of E and W, representing one of the four cardinal directions.
d is an integer which states that the direction points d degrees away from A and towards B.
A true bearing takes the form cT, where 0≤c≤359, meaning that the direction is c degrees from North in a clockwise direction.
Input
The input will be a line containing an integer n. The following n lines will each have a compass bearing for you to convert to true bearing.
Output
n lines, listing out the directions in true bearings.
Constraints
- 1≤n≤1000
- 0≤d≤45
Example 1
Input
5
N45E
S42W
N5W
S38E
N29W
45T
222T
355T
142T
331T
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.