hdu 2076 夹角有多大(题目已修改,注意读题)

点击打开链接

这是一道关于计算的题,秒会影响分,分会影响时,所以关系要理清楚,

时:e=(a)*30+0.5*b+0.5/60*c;(注意是24小时制后就可以避免)

分:d=b*6+0.1*c;

还有注意取整数不可以用%.0lf,会自动四舍五入,所以要强制转化为int就可以了

 

#include"stdio.h"
#include"math.h"
int main()
{
	int t;
	int h,m,s;
	double ans;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d",&h,&m,&s);
		if(h>12) h-=12;
		ans=fabs( (h*30+0.5*m+0.5/60*s) -(m*6+s*0.1));
		if(ans>180) ans=360-ans;
		printf("%d\n",(int)ans);
	}
	return 0;
}

posted on 2012-10-15 13:10  Slege  阅读(65)  评论(0编辑  收藏  举报

导航