Pages

Friday 28 December 2012

UVA - 438 - The Circumference of the Circle

#include <stdio.h>
#include <math.h>
#define pi 3.141592653589793

double circ(double x,double y,double z){
        double s=(x+y+z)/2;
        return (x*y*z)*pi/(2.0*sqrt(s*(s-x)*(s-y)*(s-z)));
}

double ecuD(double x1,double y1,double x2,double y2){
    return sqrt(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1)));
}

int main() {
    double x1,y1,x2,y2,x3,y3,x,y,z;
    while (scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3)==6){
        x=ecuD(x1,y1,x2,y2);
        y=ecuD(x1,y1,x3,y3);
        z=ecuD(x2,y2,x3,y3);
        printf("%.2lf\n",circ(x,y,z));
    }
    return 0;
}

No comments:

Post a Comment