What is the angle of HDU2080 II?
How large is the angle IITime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 7676 Accepted Submission (s): 3858
Problem Description the Problem with xhd is that there are two points in a plane, and the angle between the two points and the source point is calculated respectively.
Note: The angle ranges from 0,180 to. The two points do not appear at the center of the center.
The first line of Input data is a data T, indicating that T groups of data exist.
Each data set has four real numbers x1, y1, x2, and y2, respectively representing the coordinates of two points. The range of these real numbers is [-].
For each group of input data, the Output angle is precise to the two digits after the decimal point.
Sample Input
21 1 2 21 1 1 0
Sample Output
0.0045.00
Cosine formula: c ^ 2 = a ^ 2 + B ^ 2-2 abcosy;
#include
#include
#include
const double PI = acos(-1.0);int main() {// freopen("stdin.txt", "r", stdin);double x1, y1, x2, y2, a, b, c, y;int T;scanf("%d", &T);while (T--) {scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);a = x1 * x1 + y1 * y1;b = x2 * x2 + y2 * y2;c = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);printf("%.2lf\n", acos((a + b - c) / (2 * sqrt(a * b))) * 180.0 / PI);}return 0;}