Uva 438 Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long double x1, y1, x2, y2, x3, y3, a1, a2, a3, r, s, area, c;
    cout << showpoint;
    cout << fixed;
    cout << setprecision(2);
    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3)
    {
        a1 = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        a2 = sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
        a3 = sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));

        s = (a1+a2+a3)/2;

        area = sqrt(s*(s-a1)*(s-a2)*(s-a3));

        r = (a1*a2*a3)/(4*area);

        c = 2*3.141592653589793*r;
        cout << c << endl;
    }

    return 0;
}

Comments