我试图解决这个问题,但系统一直给我“错误的答案”。我检查了其他人的解决方案,我确定我的算法是正确的。有人可以帮我吗?多谢。问题:UVA 579 ClockHands
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
int hour, minute;
float hour_degree, minute_degree;
float total;
while(scanf("%d:%d",&hour, &minute) == 2)
{
if( hour == 0 && minute == 0)
break;
minute_degree = minute * 6;
hour_degree = hour * 30 + float(minute / 2);
total = fabs(hour_degree - minute_degree);
if(total > 180)
total = fabs(360 - total);
printf("%.3f\n", total);
}
return 0;
}