Angle difference between two bearings: Difference between revisions

Content added Content deleted
No edit summary
Line 86: Line 86:
60175.77 42213.07 37.30
60175.77 42213.07 37.30
</pre>
</pre>

=={{header|Befunge}}==
<lang befunge>012pv1 2 3 4 5 6 7 8
>&:v >859**%:459**1-`#v_ >12g!:12p#v_\-:459**1-`#v_ >.>
>0`#^_8v >859**-^ >859**-^
^:+**95< > ^
</lang>
The labelled points are:
1. Initialise write/not write and read input,
2. Put in the range 0-360 if negative,
3. Likewise if positive,
4. Put in range -180 - 180,
5. Check if write/not write step,
6. If write find difference,
7. Scale to -180 - 180,
8. Write out and onto next pair.

Unfortunately, due to the lack of floating-point arithmetic in befunge, it is impossible to do the full challenge, however, given the integer truncations of these values it works.

Input:
<pre>
20 45
-45 45
-85 90
-95 90
-45 125
-45 145
29 -88
-78 -159
-70099 29840
-165313 33693
1174 -154146
60175 42213
</pre>

{{out}}
<pre>
25 90 175 -175 170 -170 -117 -81 -141 -74 -160 38
</pre>

=={{header|C}}==
=={{header|C}}==
This implementation either reads two bearings from the console or a file containing a list of bearings. Usage printed on incorrect invocation.
This implementation either reads two bearings from the console or a file containing a list of bearings. Usage printed on incorrect invocation.