trying to simplify an algorithm
Archaic
archaic at linuxfromscratch.org
Thu Feb 3 06:23:17 PST 2005
The problem to solve is 3 inputs from the user. The output has to be
nothing more than equilateral, isosceles, scalene, or not a triangle. My
algorithm feels a bit clunky and I would like to streamline it if
possible. The input will be sanitized to allow only int and float (both
positive and negative) to get this far, so my only concern is just with
this algorithm.
Any suggestions?
<pseudo-code>
if a + b + c = 360
if a = b
if b = c
equilateral
else
isosceles
else
if a = c || b = c
isosceles
else
scalene
else
not a triangle
</pseudo-code>
--
Archaic
Want control, education, and security from your operating system?
Hardened Linux From Scratch
http://www.linuxfromscratch.org/hlfs
More information about the lfs-chat
mailing list