`
Dev|il
  • 浏览: 122713 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

HDU2080

 
阅读更多
角有多大II
Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3238    Accepted Submission(s): 1536


Problem Description
这次xhd面临的问题是这样的:在一个平面内有两个点,求两个点分别和原点的连线的夹角的大小。

注:夹角的范围[0,180],两个点不会在圆心出现。



Input
输入数据的第一行是一个数据T,表示有T组数据。
每组数据有四个实数x1,y1,x2,y2分别表示两个点的坐标,这些实数的范围是[-10000,10000]。



Output
对于每组输入数据,输出夹角的大小精确到小数点后两位。



Sample Input
2
1 1 2 2
1 1 1 0


Sample Output
0.00
45.00


Author
xhd


//G++ ac
#include <stdio.h>
#include <math.h>

#define PI acos(-1)

int main()
{
	double x1, x2, y1, y2, c;
	int t;
	scanf("%d", &t);
	while(t--)
	{
		scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
		if(!y1 && !y2 && x1 / y1 - x2 / y2 < 0.000001)
		{
			printf("0.00\n");
			continue;
		}
		else
			c = acos((x1 * x2 + y1 * y2) / (sqrt(x2 * x2 + y2 * y2) * sqrt(x1 * x1 + y1 * y1))) * 180 / PI;
		printf("%.2lf\n", c);
		// PI / 180 * h = c
		//h = c * 180 / pi
	}
	return 0;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics