Perl Monk, Perl Meditation | |
PerlMonks |
Finding the hypotenuse of a right triangle!by munchie (Monk) |
on Apr 08, 2002 at 23:44 UTC ( [id://157602]=CUFP: print w/replies, xml ) | Need Help?? |
Seeing this node inspired me to create a program that would allow me to find the hypotenuse of a right triangle when supplied its' A & B. It also works to find B when A & C are known. I've created two versions:
Here is the one that runs in a user interface. It is simply called as perl hypo.pl.
Here is the other version, clhypo.pl. This version isn't pretty (infact, there's no interface!) but it does the same thing. It is called like: perl clhypo.pl A B C. A, B, or C must be left out for the program to work properly. For example, perl clhypo.pl 12 - 19 find B, as - 3 5 finds A, and 7 12 - finds C.
I'm like the interfaced version better, but the command line version may suit some people. I'm not sure if this is the fastest way to compute it algorithm-wise, but I think sqrt($a**2 + $b**2) would be very fast. > munchie, the number munchin newb
Back to
Cool Uses for Perl
|
|