Реализации алгоритмов/Сортировка/Пузырьком: различия между версиями
Содержимое удалено Содержимое добавлено
DannyS712 (обсуждение | вклад) м <source> -> <syntaxhighlight> (phab:T237267) |
|||
Строка 3:
=== Синтаксис Intel ===
<
mov bx, offset array
mov cx, n
Строка 21:
exit_for_j:
loop for_i
</syntaxhighlight>
=== Синтаксис AT&T (GNU) ===
<
.text
# void bubble_sort (unsigned *array, unsigned length);
Строка 51:
exit:
ret
</syntaxhighlight>
== C ==
<
#define SWAP(A, B) { int t = A; A = B; B = t; }
Строка 71:
} while (n);
}
</syntaxhighlight>
== C++ ==
=== С использованием Template ===
<
#include <algorithm>
template< typename Iterator >
Строка 85:
std::iter_swap( i, i + 1 );
}
</syntaxhighlight>
=== Без использования Template ===
<
void bubble(int* a, int n)
{
Строка 103:
}
</syntaxhighlight>
== C++ ==
<
#include <cstddef>
Строка 125:
}
}
</syntaxhighlight>
== C# ==
<
static int[] BubbleSort(int[] mas)
{
Строка 146:
return mas;
}
</syntaxhighlight>
== Delphi ==
Сортировка одномерного динамического целочисленного массива:
<
type
Строка 172:
until n=0;
end;
</syntaxhighlight>
== D ==
<
void bubbleSort(alias op, T)(T[] inArray) {
foreach (i, ref a; inArray) {
Строка 187:
}
}
</syntaxhighlight>
== Fortran ==
<
do i=n-1,1,-1
do j=1,i
Строка 200:
end do
end do
</syntaxhighlight>
== Java ==
<
public int[] Sort(int[] array) {
int i = 0;
Строка 224:
return array;
}
</syntaxhighlight>
== Perl ==
<
for ( @out ) {
for ( 0..$#out-1 ) {
Строка 233:
}
}
</syntaxhighlight>
== Ruby ==
<
arr = [5, 20, 3, 11, 1, 17, 3, 12, 8, 10]
swap = true
Строка 250:
puts arr.join(' ')
# output => 1 3 3 5 8 10 11 12 17 20
</syntaxhighlight>
== Python ==
<
def bubble_sort(arr):
Строка 265:
assert bubble_sort([4, 3, 2, 1]) == [1, 2, 3, 4]
</syntaxhighlight>
== VBA ==
<
Sub Sort(Mus() As Long)
Dim i As Long, tmp As Long, t As Boolean
Строка 284:
Loop
End Sub
</syntaxhighlight>
== PHP ==
<
for ($i = 0; $i < count($arr); $i++){
for ($j = $i + 1; $j < count($arr); $j++) {
Строка 298:
}
}
</syntaxhighlight>
Bubble Sort
Строка 314:
== JavaScript ==
<
function sortBubble(data) {
var tmp;
Строка 333:
return data;
};
</syntaxhighlight>
== JavaScript ==
<
function bubbleSort(seq:Number[]):Number[]{
Строка 354:
return sort;
}
</syntaxhighlight>
== Nemerle ==
<
using System.Console;
using Nemerle.Collections;
Строка 369:
WriteLine($"Sorted list is a $(arr.ToList())");
</syntaxhighlight>
== [[:w:Turbo Basic|TurboBasic 1.1]]==
<
CLS
RANDOMIZE TIMER
Строка 430:
PRINT "ELAPSED TIME=";T1
�
</syntaxhighlight>
== [[:w:PL/SQL|PL/SQL]]==
<
type sort_lst is table of integer;
--------------------------------------------------------
Строка 463:
end buble_sort;
</syntaxhighlight>
== Flex, ActionScript ==
<
function bubbleSort(array:Vector.<Number>) {
for (var i:uint = 0; i < array.length; i++) {
Строка 478:
}
}
</syntaxhighlight>
== Ссылки ==
|