This problem is to ask for a point of time trouble, the idea is very simple
Just beginning to reverse the vector into swap (x, y), it should be x=-x,y=-y
#include <stdio.h> #include <math.h> #include <algorithm>using namespace Std;const double eps=1e-8; struct point {double x, y; Point () {} point (double xx,double yy) {x=xx;y=yy;} Point operator+ (point B) {return point (X+B.X,Y+B.Y);} Double operator^ (const point B) const{return x*b.y-y*b.x; } point operator-(point B) {return point (X-B.X,Y-B.Y);}}; struct line {point s,e; Line () {}; Line (point Ss,point ee) {s=ss;e=ee;} Point operator & (line B) {point res=s; Double t= ((S-B.E) ^ (B.S-B.E))/((S-E) ^ (B.S-B.E)); res.x+= (e.x-s.x) *t; res.y+= (E.Y-S.Y) *t; return res; }};d ouble Xmul (point p0,point p1,point p2) {return (p1.x-p0.x) * (P2.Y-P0.Y)-(p2.x-p0.x) * (P1.Y-P0.Y);} Double Dist (point A,point b) {return sqrt ((b.x-a.x) * (b.x-a.x) + (B.Y-A.Y) * (B.Y-A.Y));} Point GetPoint (Point a,point b,point c) {point q; Q=point (-(B.Y-A.Y), b.x-a.x); if (Xmul (a,b,c) >eps) {q.x=-q.x; Q.Y=-Q.Y; } Double D=dist (A, b); Q.X*=D/SQRT (Q.X*Q.X+Q.Y*Q.Y); Q.Y*=D/SQRT (Q.X*Q.X+Q.Y*Q.Y); q.x=a.x+q.x; Q.Y=A.Y+Q.Y; return q;} Point P[3];int Main () {#ifndef online_judgefreopen ("In.txt", "R", stdin), #endif//Online_judge int n; scanf ("%d", &n); for (int i=0;i<n;i++) {scanf ("%lf%lf%lf%lf%lf%lf", &p[0].x,&p[0].y,&p[1].x,&p[1].y,&p[2].x, &P[2].Y); Point C,d,r,q; C=getpoint (p[0],p[1],p[2]); D=getpoint (p[0],p[2],p[1]); R=point ((c.x+d.x)/2, (C.Y+D.Y)/2); C=getpoint (P[1],p[2],p[0]); D=getpoint (p[1],p[0],p[2]); Q=point ((c.x+d.x)/2, (C.Y+D.Y)/2); Point O; O=line (p[0],r) &line (P[1],Q); printf ("%.4f%.4f\n", o.x,o.y); } return 0;}
POJ 1673 Exocenter of A TRIANGLE