Sunday, August 17, 2014

uva : 438 - The Circumference of the Circle

#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
    double x1,x2,x3,y1,y2,y3,s,k,circum,a,b,c,r;
    while(scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3)==6)
    {
        a=sqrt(pow((x1-x2),2)+pow((y1-y2),2));
        b=sqrt(pow((x2-x3),2)+pow((y2-y3),2));
        c=sqrt(pow((x1-x3),2)+pow((y1-y3),2));
        s=(a+b+c)/2;
        k=sqrt(s*(s-a)*(s-b)*(s-c));
        r=(a*b*c)/(4*k);
        circum=2*3.141592653589793*r;
        printf("%.2lf\n",circum);
    }
    return 0;
}

No comments:

Post a Comment