You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
524 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
int main() {
//求三条边的长度,然后再用海伦公式进行求解
double a, b, c;
cin >> a >> b >> c;
double p = (a + b + c) / 2;
//假设在平面内,有一个三角形,边长分别为a、b、c
//三角形的面积S可由以下公式求得
//S=√[p(p-a)(p-b)(p-c)]
//而公式里的p为半周长p=(a+b+c)/2
cout << fixed << setprecision(1) << sqrt(p * (p - a) * (p - b) * (p - c)) << endl;
return 0;
}