Sorting algorithms/Bogosort: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: compressed assignment statements. -- ~~~~ |
Added XPL0 |
||
Line 1,903: | Line 1,903: | ||
1, 2, 3, 4, 4, 6, 7, 8, 11 |
1, 2, 3, 4, 4, 6, 7, 8, 11 |
||
</pre> |
</pre> |
||
=={{header|XPL0}}== |
|||
<lang XPL0>code Ran=1, ChOut=8, IntOut=11; |
|||
proc BogoSort(A, L); \Sort array A of length L |
|||
int A, L; |
|||
int I, J, T; |
|||
[loop [I:= 0; |
|||
loop [if A(I) > A(I+1) then quit; |
|||
I:= I+1; |
|||
if I >= L-1 then return; |
|||
]; |
|||
I:= Ran(L); J:= Ran(L); |
|||
T:= A(I); A(I):= A(J); A(J):= T; |
|||
]; |
|||
]; |
|||
int A, I; |
|||
[A:= [3, 1, 4, 1, -5, 9, 2, 6, 5, 4]; |
|||
BogoSort(A, 10); |
|||
for I:= 0 to 10-1 do [IntOut(0, A(I)); ChOut(0, ^ )]; |
|||
]</lang> |
|||
{{out}} |
|||
<pre> |
|||
-5 1 1 2 3 4 4 5 6 9 |
|||
</pre> |
|||
{{omit from|GUISS}} |
{{omit from|GUISS}} |