题解:将分针的角度和时针的角度都算出来,大的减小的。
#include <stdio.h>
#include <math.h>
int main() {
double m1, m2, m;
double ans, h;
while (scanf("%lf:%lf", &h, &m) && (h || m)) {
double temp1 = m * 6;
double temp2 = h * 30 + 30 * temp1 / 360;
double ans;
if (temp1 >= temp2)
ans = temp1 - temp2;
else
ans = temp2 - temp1;
if (ans > 180)
ans = 360.0 - ans;
printf("%.3lf\n", ans);
}
return 0;
}