POJ2242-The Circumference of the Circle

http://poj.org/problem?id=2242

知道外接圆半径公式就好了,r=a*b*c/(4*s),水题。

#include<stdio.h>
#include<math.h>
const double pi=3.141592653589793;
int main(void)
{
    double C,r,x1,y1,x2,y2,x3,y3,a,b,c,s,p;
    while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF)
    {
        a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
        c=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
        p=(a+b+c)*0.5;
        s=sqrt(p*(p-a)*(p-b)*(p-c));
        r=a*b*c*0.25/s;
        C=2.0*pi*r;
        printf("%.2lf\n",C);
    }
    return 0;
}
posted @ 2012-08-28 20:46  Yogurt Shen  阅读(156)  评论(0编辑  收藏  举报