首页 > 代码库 > TOJ1201

TOJ1201

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main()
{
    double a, b, c;
    double s;
    while (scanf("%lf %lf %lf",&a,&b,&c)!=EOF)
    {
        double p = (a + b + c) / 2;
        s = sqrt(p*(p - a)*(p - b)*(p - c));
        cout << setiosflags(ios::fixed) << setprecision(3) << s << endl;
    }
    return 0;
}

海伦公式:s=sqrt(p(p-a)(p-b)(p-c))

TOJ1201