Sorting algorithms/Bubble sort: Difference between revisions

no edit summary
(→‎{{header|360 Assembly}}: Replaced my old vervion with a more structured one)
No edit summary
Line 1,105:
7> bubble_sort:task().
List "asdqwe123" is sorted "123adeqsw"
</pre>
 
=={{header|ERRE}}==
sort/3 copied from Stackoverflow.
<lang ERRE>
PROGRAM BUBBLE_SORT
 
DIM FLIPS%,N,J
 
DIM A%[100]
 
BEGIN
 
! init random number generator
RANDOMIZE(TIMER)
! fills array A% with random data
FOR N=1 TO UBOUND(A%,1) DO
A%[N]=RND(1)*256
END FOR
! sort array
FLIPS%=TRUE
WHILE FLIPS% DO
FLIPS%=FALSE
FOR N=1 TO UBOUND(A%,1)-1 DO
IF A%[N]>A%[N+1] THEN
SWAP(A%[N],A%[N+1])
FLIPS%=TRUE
END IF
END FOR
END WHILE
! print sorted array
FOR N=1 TO UBOUND(A%,1) DO
PRINT(A%[N];)
END FOR
PRINT
END PROGRAM
</lang>
{{out}}
<pre>
</pre>
 
Anonymous user