HDU2080 夹角有多大2

2019-05-17

15:00:09

加油加油,fightting !!!

这道题不知道acos()函数,acos()返回的是弧度,转化成度数要 / PI * 180

也没有想到通过向量 

但是想到了余弦定理

这道题与改革春分有一点点的联系,向量

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define PI 3.1415926
int main()
{
    int t;
    int i,j;
    scanf("%d", &t);
    for(i = 0; i < t; i++)
    {
        double x1, y1, x2, y2;
        scanf ("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
        double a, b, c;
        a = x1 * x2 + y1 * y2;
        b = sqrt(x1 * x1 + y1 * y1) * sqrt(x2 * x2 + y2 * y2);
        c = acos(a / b) / PI * 180;
        printf("%.2lf
", c);
    }
    return 0;
} 
原文地址:https://www.cnblogs.com/Artimis-fightting/p/10881418.html