UVA 10242 || Fourth Point !!(求平行四边形第四点



给第一条边的两个端点,第二条边的两个端点,求平行四边形的第四个点。


给了 四个点,不一定按照 起点终点的顺序,调整一下就好了。。  A  B  B C 的顺序

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct point
{
    double x,y;
};
point p[10];
bool operator ==(point a,point b)
{
    return (a.x==b.x)&&(a.y==b.y);
}
int main()
{
   // freopen("in.txt","r",stdin);
    while( ~scanf("%lf %lf",&p[0].x,&p[0].y))
    {
       for( int i = 1;i <4;++i)
        scanf("%lf %lf",&p[i].x,&p[i].y);

        //端点给的是无序的 可能是第一条边的起点也可能是终点

        if( p[0] == p[3])
        {
            swap(p[0],p[1]);
            swap(p[2],p[3]);
        }
        else if( p[0]==p[2])
            swap(p[0],p[1]);
        else if( p[1] == p[3] )
            swap(p[2],p[3]);

        printf("%.3lf %.3lf\n",
               p[3].x-p[2].x+p[0].x,p[3].y-p[2].y+p[0].y);

    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值