Box the compass: Difference between revisions
Content added Content deleted
(Added C++) |
m (C++ improved formatting) |
||
Line 33: | Line 33: | ||
#include <iostream>; |
#include <iostream>; |
||
#include <math.h> |
#include <math.h> |
||
using std::string; |
using std::string; |
||
using namespace boost::assign; |
using namespace boost::assign; |
||
Line 71: | Line 70: | ||
case 'N' : retval += "north"; break; |
case 'N' : retval += "north"; break; |
||
case 'S' : retval += "south"; break; |
case 'S' : retval += "south"; break; |
||
case 'E' : retval += "east"; break; |
case 'E' : retval += "east"; break; |
||
case 'W' : retval += "west"; break; |
case 'W' : retval += "west"; break; |
||
case 'b' : retval += " by "; break; |
case 'b' : retval += " by "; break; |
||
} |
} |
||
} |
} |
||
Line 88: | Line 87: | ||
320.62, 320.63, 337.5, 354.37, 354.38; |
320.62, 320.63, 337.5, 354.37, 354.38; |
||
int i; |
int i; |
||
format f("%1$4d %2$- |
format f("%1$4d %2$-20s %3$_7.2f"); |
||
BOOST_FOREACH(float a, headings) |
BOOST_FOREACH(float a, headings) |
||
Line 100: | Line 99: | ||
Output: |
Output: |
||
<pre> |
<pre> |
||
1 North |
1 North 0.00 |
||
2 North by east |
2 North by east 16.87 |
||
3 North-northeast |
3 North-northeast 16.88 |
||
4 Northeast by north |
4 Northeast by north 33.75 |
||
5 Northeast |
5 Northeast 50.62 |
||
6 Northeast by east |
6 Northeast by east 50.63 |
||
7 East-northeast |
7 East-northeast 67.50 |
||
8 East by north |
8 East by north 84.37 |
||
9 East |
9 East 84.38 |
||
10 East by south |
10 East by south 101.25 |
||
11 East-southeast |
11 East-southeast 118.12 |
||
12 Southeast by east |
12 Southeast by east 118.13 |
||
13 Southeast |
13 Southeast 135.00 |
||
14 Southeast by south |
14 Southeast by south 151.87 |
||
15 South-southeast |
15 South-southeast 151.88 |
||
16 South by east |
16 South by east 168.75 |
||
17 South |
17 South 185.62 |
||
18 South by west |
18 South by west 185.63 |
||
19 South-southwest |
19 South-southwest 202.50 |
||
20 Southwest by south |
20 Southwest by south 219.37 |
||
21 Southwest |
21 Southwest 219.38 |
||
22 Southwest by west |
22 Southwest by west 236.25 |
||
23 West-southwest |
23 West-southwest 253.12 |
||
24 West by south |
24 West by south 253.13 |
||
25 West |
25 West 270.00 |
||
26 West by north |
26 West by north 286.87 |
||
27 West-northwest |
27 West-northwest 286.88 |
||
28 Northwest by west |
28 Northwest by west 303.75 |
||
29 Northwest |
29 Northwest 320.62 |
||
30 Northwest by north |
30 Northwest by north 320.63 |
||
31 North-northwest |
31 North-northwest 337.50 |
||
32 North by west |
32 North by west 354.37 |
||
1 North |
1 North 354.38 |
||
</pre> |
</pre> |
||
=={{header|Clojure}}== |
=={{header|Clojure}}== |
||
{{trans|Tcl}} |
{{trans|Tcl}} |