三大基本排序专题
//以下依次是冒泡、选择、插入排序
var n,i:longint;
a:array[0..20] of longint;
procedure BUB;
var i,j,t:longint;
begin
for i:=1 to n-1 do
for j:=1 to n-i do
if a[j]>a[j+1] then begin t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t; end;
end;
procedure SEL;
var i,j,k,t:longint;
begin
for i:=1 to n-1 do
begin
k:=i;
for j:=i+1 to n do
if a[j]<a[k] then k:=j;
t:=a[i]; a[i]:=a[k]; a[k]:=t;
end;
end;
procedure INS;
var i,j,k,t:longint;
begin
a[0]:=-2100000000;
for i:=2 to n do
begin
t:=a[i];
for j:=i-1 downto 0 do
if a[j]>t then a[j+1]:=a[j] else break;
a[j+1]:=t;
end;
end;
begin
readln(n);
for i:=1 to n do read(a[i]);
INS;
for i:=1 to n-1 do write(a[i],' ');
writeln(a[n]);
end.
a:array[0..20] of longint;
procedure BUB;
var i,j,t:longint;
begin
for i:=1 to n-1 do
for j:=1 to n-i do
if a[j]>a[j+1] then begin t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t; end;
end;
procedure SEL;
var i,j,k,t:longint;
begin
for i:=1 to n-1 do
begin
k:=i;
for j:=i+1 to n do
if a[j]<a[k] then k:=j;
t:=a[i]; a[i]:=a[k]; a[k]:=t;
end;
end;
procedure INS;
var i,j,k,t:longint;
begin
a[0]:=-2100000000;
for i:=2 to n do
begin
t:=a[i];
for j:=i-1 downto 0 do
if a[j]>t then a[j+1]:=a[j] else break;
a[j+1]:=t;
end;
end;
begin
readln(n);
for i:=1 to n do read(a[i]);
INS;
for i:=1 to n-1 do write(a[i],' ');
writeln(a[n]);
end.