Sorting algorithms/Bubble sort: Difference between revisions

m
→‎{{header|REXX}}: add Version 2 (Translation of PL/I)
m (→‎{{header|REXX}}: add Version 2 (Translation of PL/I))
Line 3,280:
 
=={{header|REXX}}==
===version 1===
<lang rexx>/*REXX program sorts an array (of any kind of items) using the bubble─sort algorithm.*/
call gen /*generate the array elements (items).*/
Line 3,364 ⟶ 3,365:
element 24 after sort: zayin
</pre>
===version 2===
{{trans|PL/I}}
<lang rexx>Call random ,,1000
Do i=1 To 10
a.i=random(20)
End
a.0=i-1
Call show 'vorher '
Call bubble_sort
Call show 'nachher'
Exit
bubble_sort: Procedure Expose a.
Do Until no_more_swaps
no_more_swaps=1
Do i=1 To a.0-1
i1=i+1
if a.i > a.i1 Then Do
temp=a.i; a.i=a.i1; a.i1=temp
no_more_swaps=0
End
End
End
Return
show:
l=''; Do i=1 To a.0; l=l a.i; End; Say arg(1)':'l
Return</lang>
{{out}}
<pre>vorher : 9 17 16 19 5 7 3 20 16 0
nachher: 0 3 5 7 9 16 16 17 19 20</pre>
 
=={{header|Ring}}==
2,299

edits