9-C language -A-1 Title: triangle area

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

Published 10 original articles · won praise 0 · Views 197

Guess you like

Origin blog.csdn.net/tianrandai12/article/details/104089289