我花了太多时间在这里寻宝,但这是Java的解决方案:
public class Aaaaarrrr {
public static void main(String[] aaarrrgs) {
float heading = Float.parseFloat(aaarrrgs[0]);
final List<String> points = Arrays.asList("North",
"North by east", "North-northeast", "Northeast by north",
"Northeast", "Northeast by east", "East-northeast",
"East by north", "East", "East by south", "East-southeast",
"Southeast by east", "Southeast", "Southeast by south",
"South-southeast", "South by east", "South", "South by west",
"South-southwest", "Southwest by south", "Southwest",
"Southwest by west", "West-southwest", "West by south", "West",
"West by north", "West-northwest", "Northwest by west",
"Northwest", "Northwest by north", "North-northwest",
"North by west");
float cp = heading / 360.0f * 32.0f;
if (cp % 1 == 0.5f)
System.out.print("Between " + points.get((int)Math.floor(cp)) + " and ");
System.out.println(points.get(Math.round(cp)));
}
}
编辑如果我将上面的代码最小化并使其变得丑陋,它将变为:
Java,770个字符
import java.util.*;class A{public static void main(String[] r){List<String> l=Arrays.asList("North","North by east","North-northeast","Northeast by north","Northeast","Northeast by east","East-northeast","East by north","East","East by south","East-southeast","Southeast by east","Southeast","Southeast by south","South-southeast","South by east","South","South by west","South-southwest","Southwest by south","Southwest","Southwest by west","West-southwest","West by south", "West","West by north","West-northwest","Northwest by west","Northwest","Northwest by north","North-northwest","North by west");float c=Float.parseFloat(r[0])/360.0f*32.0f;if (c%1==0.5f) System.out.print("Between "+l.get((int)Math.floor(c))+" and ");System.out.println(l.get(Math.round(c)));}}
'
(撇号)在一个问题中。脱下帽子!:D