Every triangle can be classified as either scalene, isosceles or equilateral:
(Some authors consider equilateral to be a special case of isosceles. For the purpose of this exercise, we use Euclid’s original definition and consider isosceles triangles those with exactly two edges of the same size.)
All triangles can also be classified as right, obtuse and acute:
Write a program that given three edge sizes determines:
Input consists of a several lines, each with three natural numbers x, y and z where
0 < x, y, z < 10 000
For each line of input, output should contain a line indicating both classifications or impossible
.
3 4 5
3 3 1
6 4 3
1 1 1
7 2 3
scalene right
isosceles acute
scalene obtuse
equilateral acute
impossible
If are having trouble to get a full score in this exercise, try to come up with other test cases besides the ones given on the example inputs. Does your program still produce the expected results on them? What if you change the order in which the sides are given?
try first: triangle1
try next: calc
Copyright © 2020-2022 Rudy Matela
This text is available under the CC BY-SA 4.0 license.
Originally available on cscx.org/triangle