这个题目没得说,就直接套用三角形外心的模板就可以了。这个题目可以作为三角形外心的模板来用了。
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;
#define PI 3.141592653589793
struct point
{
double x;
double y;
};
struct Line
{
point a;
point b;
};
point intersection(Line u,Line v)
{
point res=u.a;
double k=((u.a.x-v.a.x)*(v.a.y-v.b.y)-(u.a.y-v.a.y)*(v.a.x-v.b.x))/((u.a.x-u.b.x)*(v.a.y-v.b.y)-(u.a.y-u.b.y)*(v.a.x-v.b.x));
res.x+=(u.b.x-u.a.x)*k;
res.y+=(u.b.y-u.a.y)*k;
return res;
}
point circumcenter(point a,point b,point c)
{
Line u,v;
u.a.x=(a.x+b.x)/2;
u.a.y=(a.y+b.y)/2;
u.b.x=u.a.x-a.y+b.y;
u.b.y=u.a.y+a.x-b.x;
v.a.x=(a.x+c.x)/2;
v.a.y=(a.y+c.y)/2;
v.b.x=v.a.x-a.y+c.y;
v.b.y=v.a.y+a.x-c.x;
return intersection(u,v);
}
double dis(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int main()
{
point a,b,c;
while(scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y)!=EOF)
{
point ans=circumcenter(a,b,c);
printf("%.2lf\n",dis(ans,a)*PI*2);
}
return 0;
}