Saturday, February 26, 2011

438 - The Circumference of the circle


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    long double x1,y1,x2,y2,x3,y3,r,a,b,c;
    long double x12,x23,x31,y12,y23,y31,s,A,cir;
    freopen("in.txt","r",stdin);
    while(scanf("%Lf%Lf%Lf%Lf%Lf%Lf",&x1,&y1,&x2,&y2,&x3,&y3)==6)
    {
        x12=x1-x2,x12*=x12,y12=y1-y2,y12*=y12;
        x23=x2-x3,x23*=x23,y23=y2-y3,y23*=y23;
        x31=x3-x1,x31*=x31,y31=y3-y1,y31*=y31;
        a=sqrt(x12+y12),b=sqrt(x23+y23),c=sqrt(x31+y31);
        s=(a+b+c)/2,A=sqrt(s*(s-a)*(s-b)*(s-c));
        r=(a*b*c)/(4*A);
        cir=3.141592653589793*r*2;
        printf("%0.2Lf\n",cir);
    }
    exit(0);
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.