Anonymous user
Largest int from concatenated ints: Difference between revisions
Largest int from concatenated ints (view source)
Revision as of 06:17, 30 January 2018
, 6 years ago→{{header|REXX}}: changed for format of the first two REXXes lists, added verbiage to the output.
m (→exponentiated integers: added wording to the version section header.) |
m (→{{header|REXX}}: changed for format of the first two REXXes lists, added verbiage to the output.) |
||
Line 1,954:
===simple integers===
<lang rexx>/*REXX program constructs the largest integer from an integer list using concatenation.*/
@.=.; @.1 = '
@.2 = '
@.3 = '
w=0 /* [↓] process all the integer lists.*/
do j=1 while
do
▲ do k=2 to words(z); #=norm(k) /*obtain an a number from the list. */
L=max(length(big), length(#) ) /*get the maximum length of the integer*/
if left(#, L, left(#, 1) ) <<= left(big, L, left(big, 1) ) then iterate
Line 1,970 ⟶ 1,969:
$=$ || big /*append " " " ───► $. */
end /*while z*/ /* [↑] process all integers in a list.*/
end
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
norm: arg i; #=word(z, i); er=' ***error*** ';
if \datatype(#,'W') then do; say er 'number' # "isn't an integer.";
return #/1 /*it's an integer, then normalize it. */</lang>
{{out|output|text= when using the default (internal) integer lists:}}
<pre>
</pre>
Line 1,994 ⟶ 1,993:
<br>digits, but displaying the result would be problematic for results wider than the display area).
<lang rexx>/*REXX program constructs the largest integer from an integer list using concatenation.*/
@.=.; @.1 = '
@.2 = '
@.3 = '
@.4 = '
w=0 /* [↓] process all the integer lists.*/
do j=1 while
do while z\=''; idx=1; big=norm(1) /*keep examining the list until done.*/
do k=2 to words(z); #=norm(k) /*obtain an a number from the list. */
Line 2,011 ⟶ 2,009:
$=$ || big /*append " " " ───► $. */
end /*while z*/ /* [↑] process all integers in a list.*/
end
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
norm: arg i; #=word(z, i); er=' ***error*** ';
if \datatype(#,'N') then do; say er 'number' # "isn't an number."; exit 13; end
else #= abs(#) / 1 /*a #, so normalize it*/
Line 2,025 ⟶ 2,023:
{{out|output|text= when using the default (internal) integer lists:}}
<pre>
</pre>
|