这道简单的题目为什么还要写解题报告呢?就是因为自己经常犯一个小错误,就是1.0*s/60这样的老是写成了0.1了,这样以后找错比较麻烦,所以还是吧代码贴了下来
source code:
//此题思路:以12点为参考系,计算到12点的夹角
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int t, h, m, s;
double degree, hdegree, mdegree;
cin>>t;
while (t--)
{
cin>>h>>m>>s;
if (h>12)
{
h=h-12;
}
hdegree = 30.0*h+(1.0*m/60.0+1.0*s/3600.0)*30.0;
//cout<<"hdegree = "<<hdegree<<endl;
mdegree = 6.0*m+1.0*s/60.0*6.0;
//cout<<"mdegree = "<<mdegree<<endl;
degree = fabs(hdegree-mdegree);
if (degree > 180.0)
{
degree = 360.0-degree;
}
cout<<(int)degree<<endl;
}
return 0;
}