POJ 1673 EXOCENTER OF A TRIANGLE(垂心)

题目链接

折腾了半天,没想出怎么证明,以前初中老师教过,不知道怎么办,就量量。。。受不了,怒抄模版1Y。。。

 1 #include <cstdio>

 2 #include <iostream>

 3 using namespace std;

 4 #define eps 1e-8

 5 struct point

 6 {

 7     double x,y;

 8 };

 9 struct line

10 {

11     point a,b;

12 };

13 point intersection(line u,line v)

14 {

15     point ret = u.a;

16     double t = ((u.a.x-v.a.x)*(v.a.y-v.b.y)-(u.a.y-v.a.y)*(v.a.x-v.b.x))

17     /((u.a.x-u.b.x)*(v.a.y-v.b.y)-(u.a.y-u.b.y)*(v.a.x-v.b.x));

18     ret.x += (u.b.x-u.a.x)*t;

19     ret.y += (u.b.y-u.a.y)*t;

20     return ret;

21 }

22 point perpencenter(point a,point b,point c)

23 {

24     line u,v;

25     u.a = c;

26     u.b.x = u.a.x - a.y + b.y;

27     u.b.y = u.a.y + a.x - b.x;

28     v.a = b;

29     v.b.x = v.a.x - a.y + c.y;

30     v.b.y = v.a.y + a.x - c.x;

31     return intersection(u,v);

32 }

33 int main()

34 {

35     int t;

36     point a,b,c;

37     scanf("%d",&t);

38     while(t--)

39     {

40         scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y);

41         a = perpencenter(a,b,c);

42         printf("%.4f %.4f\n",a.x+eps,a.y+eps);

43     }

44     return 0;

45 }

 

 

你可能感兴趣的:(poj)