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.

25 lines
832 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
int main() {
//cin读入优化
std::ios::sync_with_stdio(false);
float x1, y1, x2, y2, x3, y3;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
//求三条边的长度,然后再用海伦公式进行求解
double a, b, c;
a = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
b = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
c = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
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(2) << sqrt(p * (p - a) * (p - b) * (p - c)) << endl;
return 0;
}