Tuesday, September 9, 2014

UVa Solution 438 - The Circumference of the Circle

#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
#define PI 3.141592653589793

int main()
{
    double x1, x2, x3, y1, y2, y3;
    double a, b, c, d, s, r, area, cir;
    while(cin>>x1>> y1>>x2>>y2>>x3>>y3)
    {
        a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        b=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
        c=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
        s=(a+b+c)/2;
        area=sqrt(s*(s-a)*(s-b)*(s-c));
        d=(a*b*c)/(2*area);
        r=(d/2);
        cir=(2*PI*r);
        printf("%0.2lf\n", cir);
    }
    return 0;
}

No comments:

Post a Comment

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...