Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
15
Task/Knuth-shuffle/SETL/knuth-shuffle.setl
Normal file
15
Task/Knuth-shuffle/SETL/knuth-shuffle.setl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
program knuth_shuffle;
|
||||
setrandom(0);
|
||||
|
||||
array := [1..10];
|
||||
print("Before shuffling:", array);
|
||||
shuffle(array);
|
||||
print("After shuffling: ", array);
|
||||
|
||||
proc shuffle(rw tup);
|
||||
loop for i in [1..#tup-1] do
|
||||
j := random [i+1..#tup];
|
||||
[tup(i), tup(j)] := [tup(j), tup(i)];
|
||||
end loop;
|
||||
end proc;
|
||||
end program;
|
||||
Loading…
Add table
Add a link
Reference in a new issue