all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,20 @@
|
|||
sub shell_sort ( @a is copy ) {
|
||||
loop ( my $gap = (@a/2).round; $gap > 0; $gap = ( $gap * 5 / 11 ).round ) {
|
||||
for $gap .. @a.end -> $i {
|
||||
my $temp = @a[$i];
|
||||
|
||||
my $j;
|
||||
loop ( $j = $i; $j >= $gap; $j -= $gap ) {
|
||||
my $v = @a[$j - $gap];
|
||||
last if $v <= $temp;
|
||||
@a[$j] = $v;
|
||||
}
|
||||
|
||||
@a[$j] = $temp;
|
||||
}
|
||||
}
|
||||
return @a;
|
||||
}
|
||||
my @data = 22, 7, 2, -5, 8, 4;
|
||||
say 'input = ' ~ @data;
|
||||
say 'output = ' ~ @data.&shell_sort;
|
||||
Loading…
Add table
Add a link
Reference in a new issue