#t218. 计算三角形面积

计算三角形面积

Area of a Triangle

Problem Description

Given a triangle on the plane whose three vertices have coordinates (x1,y1),(x2,y2),(x3,y3)(x_1, y_1), (x_2, y_2), (x_3, y_3), compute the area of this triangle.

Input Format

A single line containing 66 floating-point numbers, corresponding to x1,y1,x2,y2,x3,y3x_1, y_1, x_2, y_2, x_3, y_3.

Output Format

A single line containing the area of the triangle, accurate to two decimal places.

Sample Input

0 0 4 0 0 3

Sample Output

6.00

Hint

  • There are 6 numbers in the input: the coordinates of the three vertices.
  • You cannot plug the coordinates directly into Heron's formula — first compute the three side lengths (use the distance-between-two-points formula), then follow the procedure from the previous problem.
  • Keep 2 decimal places. Check against the sample: 0 0 4 0 0 3 → side lengths 3, 4, 5 → 6.00.

Heron's formula: let the three side lengths be a,b,ca,b,c, set p=a+b+c2p=\frac{a+b+c}{2}, then the area S=p(p−a)(p−b)(p−c)S=\sqrt{p(p-a)(p-b)(p-c)}.