Anonymous user
Paraffins: Difference between revisions
m
→{{header|REXX}}: simplified code, changed comments, split some compound statements, added whitespace.
(Added alternative solution for Pascal.) |
m (→{{header|REXX}}: simplified code, changed comments, split some compound statements, added whitespace.) |
||
Line 2,576:
Programming note: the biggest concern was calculating the number of numeric digits (so as to avoid integer overflow).
<lang rexx>/*REXX
parse arg nodes . /*obtain optional argument from the CL.*/
if nodes=='' | nodes=="," then nodes= 100 /*Not specified? Then use the default.*/
Line 2,585:
say right(0, w) unrooted.0 /*show enumerations of 0 carbon atoms*/
/* [↓] process all nodes (up to NODES)*/
do C=1 for nodes; h= C % 2
call tree 0, C, C, 1, 1 /* [↓] if # of carbon atoms is even···*/
if \(C//2
say right(C, w) unrooted.C /*display an aligned formatted number. */
end /*C*/
Line 2,593:
/*──────────────────────────────────────────────────────────────────────────────────────*/
tree: procedure expose rooted. unrooted. nodes #. /*this function is recursive.*/
parse arg br,n,L,sum,cnt;
brp= br + 1
if b==4
if
do m=nm by -1 for nm; call tree b, m, L, sum, #.br
end /*m*/
end /*b*/ /* ↑↑↑↑↑↑↑↑↑ recursive. */
return</lang>
{{out|output|text= when using the input of: <tt> 600 </tt>}}
|