Реализации алгоритмов/Сортировка/Шелла: различия между версиями

Содержимое удалено Содержимое добавлено
м Reverted 1 edit by 92.255.196.203 (talk) to last revision by 37.186.101.229. (TW)
Метка: отмена
м <source> -> <syntaxhighlight> (phab:T237267)
Строка 24:
 
== [[w:Си (язык программирования)|Cи]] ==
<sourcesyntaxhighlight lang="c">
/* Пример из книги Герберта Шилдта */
void shell(char *items, int count)
Строка 43:
}
}
</syntaxhighlight>
</source>
 
== [[w:C++|C++]] ==
<sourcesyntaxhighlight lang="cpp">
int increment(long inc[], long size) {
// inc[] массив, в который заносятся инкременты
Строка 94:
}
 
</syntaxhighlight>
</source>
 
== [[w:VBA|VBA]] ==
<sourcesyntaxhighlight lang="vb">
Sub Sort(Mus() As Long)
Dim i As Long, k As Long, Pos As Long
Строка 124:
Loop Until k = 1
End Sub
</syntaxhighlight>
</source>
 
== [[w:C Sharp|C#]] ==
<sourcesyntaxhighlight lang="cpp">
public void SheelSorting(int[] arr)
{
Строка 146:
}
}
</syntaxhighlight>
</source>
Этот более быстрый
<sourcesyntaxhighlight lang="cpp">
private void shellSort(int[] vector)
{
Строка 165:
}
}
</syntaxhighlight>
</source>
 
== [[w:Java|Java]] ==
<sourcesyntaxhighlight lang="java">
void sort_shell(int[] a){
int i, j, k, h, m=0, b=a.length;
Строка 188:
}
}
</syntaxhighlight>
</source>
 
== [[w:Delphi (язык программирования)|Object Pascal (Delphi)]] ==
<sourcesyntaxhighlight lang="pascal">
var
incr: array [0..23] of integer = (1, 4, 10, 23, 57, 145, 356, 911, 1968, 4711,
Строка 234:
until not (cur_inc <> -1);
end;
</syntaxhighlight>
</source>
 
== [[w:PHP|PHP]] ==
<sourcesyntaxhighlight lang="php">
function ShellSort($elements,$length) {
$k=0;
Строка 267:
// $SortedElements=shellsort($UnsortedElements,length of list(an integer));
// e.g: $elements=shellsort($elements,10);
</syntaxhighlight>
</source>
 
== [[w:Python|Python]] ==
<sourcesyntaxhighlight lang="python">
import numpy
def shellsort(a):
Строка 289:
a[j],a[j - increment] = a[j - increment],a[j]
return a
</syntaxhighlight>
</source>
 
== [[w:Ruby|Ruby]] ==
<sourcesyntaxhighlight lang="ruby">
n = mass.size - 1
d = n/2
Строка 304:
end
puts mass
</syntaxhighlight>
</source>
 
== [[w:Perl|Perl]] ==
<sourcesyntaxhighlight lang="perl">
use warnings;
use strict;
Строка 340:
#1 2 3 3 3 4 5 5 6 7 7 9 9
 
</syntaxhighlight>
</source>
 
== [[w:Perl_v2|Perl (вариант 2)]] ==
<sourcesyntaxhighlight lang="perl">
use feature 'say';
 
Строка 357:
}
}
</syntaxhighlight>
</source>
 
== [[w:Perl 6|Perl 6]] ==
<sourcesyntaxhighlight lang="perl6">
my @a = <5 3 7 9 2 1 6 5 3 7 9 3 1>;
loop (my $k = @a.elems div 2; $k > 0; $k div= 2) {
Строка 368:
}
say @a;
</syntaxhighlight>
</source>
 
== [[w:PL/SQL|PLSQL]] ==
<sourcesyntaxhighlight lang="plsql">
type sort_lst is table of integer;
----------------------Шеллосортировка-----------------------------------------------
Строка 401:
end Shell_sort;
------------------------------------------------------------------------------------
</syntaxhighlight>
</source>
 
{{BookCat | filing = deep}}