Law of cosines - triples: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added wording to the REXX section header.)
m (→‎{{header|REXX}}: changed the wording in the REXX section headder.)
Line 378: Line 378:
This REXX version used some optimization.
This REXX version used some optimization.


Instead of coding a general purpose subroutine (or function) to solve all of the
Instead of coding a general purpose subroutine (or function) to solve all of the
task's requirements,   it was decided
task's requirements,   it was decided to
<br>to write three very-similar &nbsp; '''do''' &nbsp; loops (triple nested) to provide the
<br>write three very similar &nbsp; '''do''' &nbsp; loops (triple nested) to provide the
answers for the three requirements.
answers for the three requirements.


Three arguments &nbsp; (from the command line) &nbsp; can be specified which indicates the
Three arguments &nbsp; (from the command line) &nbsp; can be specified which indicates the
maximum number of triangle sides
maximum length of the triangle sides
<br>(the default is &nbsp; '''13''', &nbsp; as per the task's requirement) &nbsp; for each of the
<br>(the default is &nbsp; '''13''', &nbsp; as per the task's requirement) &nbsp; for each of the
three types of angles &nbsp; ('''60º''', '''90º''', and '''120º''') &nbsp; for
three types of angles &nbsp; ('''60º''', '''90º''', and '''120º''') &nbsp; for
<br>the triangles. &nbsp; If the number of sides is positive, &nbsp; it indicates that the
<br>the triangles. &nbsp; If the maximum length of the triangle's number of
triangle sides are displayed, &nbsp; as well as a total
sides is positive, &nbsp; it indicates that the triangle sides are
<br>number of triangles found.
<br>displayed, &nbsp; as well as a total number of triangles found.

If the number of sides is negative, &nbsp; only the &nbsp; ''number'' &nbsp; of triangles are
displayed &nbsp; (using the absolute value of the
<br>negative number).


If the maximum length of the triangle sides is negative, &nbsp; only
the &nbsp; ''number'' &nbsp; of triangles are
displayed &nbsp; (using the
<br>absolute value of the negative number).
<lang rexx>/*REXX pgm finds integer sided triangles that satisfy Law of cosines for 60º, 90º, 120º.*/
<lang rexx>/*REXX pgm finds integer sided triangles that satisfy Law of cosines for 60º, 90º, 120º.*/
parse arg s1 s2 s3 . /*obtain optional arguments from the CL*/
parse arg s1 s2 s3 . /*obtain optional arguments from the CL*/