for i:=1 to (n-1) do
begin
for j:=1 to (n-1) do
begin
if A[j]>A[j+1] then
begin
t:=A[j];
A[j]:=A[j+1];
A[j+1]:=t;
end;
end;
end;
Uses crt;
Const N = 20;
var ms : array [1..N] of integer;
i : integer;
procedure BUBLE(var w: array of integer) ;
var i, j, d : integer;
begin
for i:=1 to N-1 do
for j:=i+1 to N do
if w[i]> w[j] then
begin d:= w[i];
w[i]:=w[j];
w[j]:=d;
end;
end;
begin
Clrscr;
randomize;
for i:=1 to N do
begin
ms[i]:=random(15)-7;
write (ms[i]:3);
end;
writeln;
Buble (ms);
for i:=1 to N do write (ms[i]:3);
readkey;
end.
procedure sortBubble (Var A: array [1..n] of integer);
Var i, j: byte;
t: integer;
Begin
for i:=1 to (n-1) do
for j:=i to (n-1) do
if A[j]>A[j+1]
then
begin
t:=A[j];
A[j]:=A[j+1];
A[j+1]:=t
end
End;