V
V
Vlad_Radigin2019-02-02 19:38:44
Python
Vlad_Radigin, 2019-02-02 19:38:44

How to solve the problem of determining the three sides of a triangle?

Task:
Determine the type of triangle (acute-angled, obtuse-angled, right-angled) with the given sides.
You must output one of the words: "right" for a right triangle, "acute" for an acute triangle, "obtuse" for an obtuse triangle, or "impossible" if the input numbers do not form a triangle.
What's wrong with my way?
a = int(input())
b = int(input())
c = int(input())
if pow(c, 2) == pow(a, 2) + pow(b, 2):
print(' right')
elif pow(b, 1) + pow(c, 2) - pow(a, 2) > 0:
print('acute')
elif pow(a, 2) + pow(b, 2) < pow( c, 2):
print('obtuse')
elif (a + b) <= c or (a + b) <= b or (c + b) <= a:

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
longclaps, 2019-02-02
@Vlad_Radigin

I would use the law of cosines
Thick, xoo )
a, b, c = 3, 4, 5
a, b, c = sorted([a, b, c])
if a + b <= c:
    print('impossible')
else:
    t = a * a + b * b - c * c
    print(('right', 'obtuse', 'acute')[(t < 0) - (t > 0)])

X
xoo, 2019-02-02
@xoo

I would use the cosine theorem , find the angles, and then draw the conclusion.
I don’t know what’s going on here, but the dimensions don’t converge here
pow(b, 1) + pow(c, 2) - pow(a, 2) > 0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question