uva 10250

题意:已经两条线段互相垂直平分,且告诉你其中一条线段的两个端点,让你求另外两个点

这里用到了:

先让中点变成原点

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
    double x1,x2,x3,x4,y1,y2,y3,y4,ox,oy;

    while (cin>>x1>>y1>>x2>>y2)
    {
        if (x1 == x2 && y1 == y2)
            printf("Impossible.\n");
        else 
        {
            ox = (x1+x2)/2;
            oy = (y1+y2)/2;
            x1 -= ox,x2 -= ox;
            y1 -= oy,y2 -= oy;
            x3 = -y1,y3 = x1;
            x4 = -x3,y4 = -y3;
            printf("%lf %lf %lf %lf\n",x3+ox,y3+oy,x4+ox,y4+oy);
        }
    }
    return 0;
}


你可能感兴趣的:(uva 10250)