Last list item: Difference between revisions
Content added Content deleted
Line 490: | Line 490: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
=== |
===With sorting=== |
||
<lang |
<lang> |
||
see "working..." + nl |
see "working..." + nl |
||
Line 499: | Line 499: | ||
while true |
while true |
||
n++ |
n++ |
||
List = sort(List) |
|||
⚫ | |||
⚫ | |||
ind1 = find(List,first) |
ind1 = find(List,first) |
||
⚫ | |||
⚫ | |||
ind2 = find(List,second) |
ind2 = find(List,second) |
||
if ind1 < ind2 |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
sum = first + second |
sum = first + second |
||
add(List,sum) |
add(List,sum) |
||
Line 536: | Line 542: | ||
see txt + nl |
see txt + nl |
||
</lang> |
</lang> |
||
=== |
===Without sorting=== |
||
<lang> |
<lang ring> |
||
see "working..." + nl |
see "working..." + nl |
||
Line 545: | Line 551: | ||
while true |
while true |
||
n++ |
n++ |
||
first = min(List) |
|||
⚫ | |||
⚫ | |||
ind1 = find(List,first) |
ind1 = find(List,first) |
||
⚫ | |||
⚫ | |||
ind2 = find(List,second) |
ind2 = find(List,second) |
||
del(List,ind2) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
sum = first + second |
sum = first + second |
||
add(List,sum) |
add(List,sum) |