#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
int h, m;
double a1, a2,angle;
char c;
while(cin>>h>>c>>m)
{
if(!h&&!m)break;
if(h==12)h = 0;
a1 = (h+m/60.0)*30.0;
a2 = m*6.0;
angle = a2 - a1; //cout<<a1<<" "<<a2<<endl;cout<<angle<<"->";
//if(angle<-180)angle+=360;
if(angle<0)angle *= -1;
angle = angle < 360 - angle ? angle : 360 - angle;
//if(angle<0)angle += 360;
//while(angle>180)
// angle -=180;
cout<<fixed<<setprecision(3)<<angle<<endl;
}
return 0;
}
此题思路错误
我拿angle与180相加减,如碰见181这样的值就不行了。所以这次我败在了思路上。啊啊啊啊啊啊!@