给定三条中线长,求三角形面积
思路:copy一个别人的题解
代码:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
double a, b, c;
bool judge() {
if (a + b > c && a + c > b && b + c > a) return true;
return false;
}
double gao() {
double p = (a + b + c) / 2;
return sqrt(p * (p - a) * (p - b) * (p - c)) / 3 * 4;
}
int main() {
while (~scanf("%lf%lf%lf", &a, &b, &c)) {
if (!judge()) printf("-1.000\n");
else {
printf("%.3f\n", gao());
}
}
return 0;
}