杭电acm--2080

来源:互联网 发布:上海建模软件培训班 编辑:程序博客网 时间:2024/05/23 01:56


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

注:夹角的范围[0,180],两个点不会在圆心出现。
 
Input
输入数据的第一行是一个数据T,表示有T组数据。
每组数据有四个实数x1,y1,x2,y2分别表示两个点的坐标,这些实数的范围是[-10000,10000]。
 
Output
对于每组输入数据,输出夹角的大小精确到小数点后两位。
 

#include<iostream>#include<cmath>#include<iomanip>#define P 3.141592653using namespace std;void main(){double  x1, y1, x2, y2,t=0.00;double result;int n;cin >> n;while (n--){cin >> x1 >> y1 >> x2 >> y2;if (x1 / y1 == x2 / y2)cout << fixed<<setprecision(2)<<t << endl;elsecout <<fixed<<setprecision(2)<<( acos((pow(x1, 2) + pow(y1, 2) + pow(x2, 2) + pow(y2, 2) - pow( (x1 - x2), 2 ) - pow( (y1 - y2), 2) ) /(2 * sqrt(pow(x1, 2) + pow(y1, 2) )*sqrt(pow(x2, 2) + pow(y2, 2) )) ))* 180 / P << endl;}system("pause");}


0 0
原创粉丝点击