右边是double型的数值,而左边有整数时,给整数*1.0.
i
#include<stdio.h>
#include<math.h>
int main()
{
int t,h,m,s,i,j;
double dh,dm,ans;
scanf("%d",&t);
for(i=0;i<t;i++)
{dh=0.0;
dm=0.0;
scanf("%d%d%d",&h,&m,&s);
if(h>=12)
h-=12;
dh=1.0*h/12*360+(1.0*m/2)+s*1.0/120; //
dm=1.0*m*6+1.0*s/10;
//printf("%f %f\n",dh,dm);
if(dh>dm)
ans=dh-dm;
else
ans=dm-dh;
if(ans>180)
ans=360.0-ans;
printf("%.0lf\n",floor(ans));
}
return 0;
}