Title: Triangle area
Three vertices of the triangle are known in the rectangular coordinate system coordinates are:
(2.3, 2.5)
(6.4, 3.1)
(5.1, 7.2)
Find the area of a triangle.
Note that to submit a floating-point number is represented in decimal form.
It requires accurate to three decimal places, such as less than 3, zero padding required.
代码:x1=2.3
y1=2.5
x2=6.4
y2=3.1
x3=5.1
y3=7.2
s=(x1*y1+x2*y3+x3*y1-x1*y3-x2*y1-x3*y2)/2
print("s=%.3f"%s)
answer:
s=8.105