C#,163152字节
这将创建每只手两次以进行环绕计数,然后遍历每种组合并找到手之间的最小角度。计算以60除法进行,然后乘以6得到度。
为了清楚起见缩进:
float F(int s){
float b=60,c;
float[]a={c=s/b/b%12*5,c+b,c=s/b%b,c+b,s%=60,s+b};
for(s=36;s-->0;)
b=s%6!=s/6&(c=(c=a[s%6]-a[s/6])<0?-c:c)<b?c:b;
return b*6;
}
输出示例:
0 seconds, 00:00:00, smallest angle is 0°
43200 seconds, 12:00:00, smallest angle is 0°
86399 seconds, 23:59:59, smallest angle is 0.09164429°
3330 seconds, 00:55:30, smallest angle is 54.75°
39930 seconds, 11:05:30, smallest angle is 60.25001°
21955 seconds, 06:05:55, smallest angle is 65.49998°
21305 seconds, 05:55:05, smallest angle is 59.50001°
5455 seconds, 01:30:55, smallest angle is 75.45831°
41405 seconds, 11:30:05, smallest angle is 44.95834°