HDU 2080 夹角有多大II

简单题,不解释,不过,貌似我现在也就能做做简单的数学题了。

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
const double pi=acos(-1.0);
using namespace std;
void f(double &angle,double x,double y)
{
    if(x<0&&y<0)
        angle+=180.0;
    else if(x>=0&&y<0)
        angle+=360.0;
    else if(x<0&&y>=0)
        angle+=180.0;
}
int main()
{
    int t;
    double x1,y1,x2,y2;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
        double angle1=atan(y1/x1)*180.0/pi;
        double angle2=atan(y2/x2)*180.0/pi;
        f(angle1,x1,y1);
        f(angle2,x2,y2);
        //printf("%lf,%lf\n",angle1,angle2);
        double d=angle1-angle2;
        //printf("d=%lf\n",d);
        if(d<0)
            d=-d;
        if(d>180)
            d=360-d;
        printf("%.2lf\n",d);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值