Box the compass: Difference between revisions

Box the compass en QBasic
(Box the compass en QBasic)
Line 5,808:
32 North by west 354.37°
1 North 354.38°</pre>
 
 
=={{header|QBasic}}==
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
{{trans|Liberty BASIC}}
<lang qbasic>DECLARE FUNCTION compasspoint$ (h!)
 
DIM SHARED point$(32)
FOR i = 1 TO 32
READ d$: point$(i) = d$
NEXT i
FOR i = 0 TO 32
heading = i * 11.25
IF (i MOD 3) = 1 THEN
heading = heading + 5.62
ELSE
IF (i MOD 3) = 2 THEN heading = heading - 5.62
END IF
ind = i MOD 32 + 1
PRINT ind, compasspoint$(heading), heading
NEXT i
END
DATA "North ", "North by east ", "North-northeast ", "Northeast by north"
DATA "Northeast ", "Northeast by east ", "East-northeast ", "East by north "
DATA "East ", "East by south ", "East-southeast ", "Southeast by east "
DATA "Southeast ", "Southeast by south", "South-southeast ", "South by east "
DATA "South ", "South by west ", "South-southwest ", "Southwest by south"
DATA "Southwest ", "Southwest by west ", "West-southwest ", "West by south "
DATA "West ", "West by north ", "West-northwest ", "Northwest by west "
DATA "Northwest ", "Northwest by north", "North-northwest ", "North by west "
 
FUNCTION compasspoint$ (h)
x = h / 11.25 + 1.5
IF (x >= 33!) THEN x = x - 32!
compasspoint$ = point$(INT(x))
END FUNCTION</lang>
 
 
=={{header|Racket}}==
2,122

edits