Anonymous user
Equilibrium index: Difference between revisions
m
→version 1: added/changed whitespace, use a template for the output sections.
(Added Wren) |
m (→version 1: added/changed whitespace, use a template for the output sections.) |
||
Line 2,261:
<lang rexx>/*REXX program calculates and displays the equilibrium index for a numeric array (list).*/
parse arg x /*obtain the optional arguments from CL*/
if x='' then x= copies(" 7 -7", 50) 7
say ' array list: ' space(x) /*echo the array list to the terminal. */
#= words(x)
do j=0 for #;
end /*j*/ /* [↑] assign @.0 @.1 @.3 ··· */
say /* ··· and also display a blank line. */
answer= equilibriumIDX();
say 'equilibrium' word("(none) index: indices:", 1 + (w>0) + (w>1)) answer
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
equilibriumIDX: $=;
return $ /*return equilibrium list (may be null)*/</lang>
<pre>
array list: -7 1 5 2 -4 3 0
Line 2,282:
equilibrium indices: 3 6
</pre>
<pre>
array list: 2 9 2
Line 2,288:
equilibrium index: 1
</pre>
<pre>
array list: 5 4 4 5
Line 2,294:
equilibrium (none)
</pre>
<pre>
array list: 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7 -7 7
|