做华南师范大学校赛初赛的一道计算几何题,无聊暴力推公式。
#include<stdio.h>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
double x1,y1,x2,y2,x3,y3,x0,y0,r;
while(~scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3))
{
x0=((y3-y1)*(y2*y2-y1*y1)+(y3-y1)*(x2*x2-x1*x1)-(y1-y2)*(y1*y1-y3*y3)-(y1-y2)*(x1*x1-x3*x3))/(2*(y1-y2)*(x3-x1)-2*(y3-y1)*(x1-x2));
y0=(y3*y3-y1*y1-2*x0*(x3-x1)-x1*x1+x3*x3)/(2*(y3-y1));
r=sqrt((y0-y2)*(y0-y2)+(x0-x2)*(x0-x2));
printf("%.2lf %.2lf %.2lf\n",x0,y0,r);
}
return 0;
}