The task is as follows: 6 numbers are entered - coordinates of three vertices of the triangle. It is necessary to find its area. In the testing system, this code fails 1 test. In what cant I do not know. Python 3.3
Input data:
Six numbers - the coordinates of the three vertices of the triangle.
Output:
One number - the size of the area of the triangle.
Examples
input data:
1 1 2 4 3 2
output:
2.50000
As for the accuracy of calculations and rounding, the condition says nothing, tried differently, did not help.
import math x1, y1, x2, y2, x3, y3 = list(map(int, input().split())) a = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) b = math.sqrt((x3 - x1) ** 2 + (y3 - y1) ** 2) c = math.sqrt((x2 - x3) ** 2 + (y2 - y3) ** 2) p = (a + b + c) / 2 res = math.sqrt(p * (p - a) * (p - b) * (p - c)) print(res)
A = abs( x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2) ) / 2.0- MaxU