Program sortuje rekordy.
program rekordy;
type cos=record;
pole1:integer;
pole2:integer;
end;
const maxroz=10;
var tab:array[1..max] of cos;
i,j,m,pom:integer;
pom1:char;
begin
write('podaj rozmiar tablicy');
read(n);
randomize;
for i:=1 to n do
begin
tab[i].pole1:=random(3);
tab[i].pole2:=chr(65+randome(3));
writeln(tab[i].pole1,' ',tab[i].pole2);
end;
for i:=2 to n do
begin
j:=i;
while(j>1) and (tab[j-1].pole1>tab[j].pole1) do
begin
pom:=tab[j].pole1;
pom1:=tab[j].pole2;
tab[j].pole1:=tab[j-1].pole1;
tab[j].pole2:=tab[j-1].pole2;
tab[j-1].pole1:=pom;
tab[j-1].pole2:=pom1;
j:=j-1;
end;
end;
for i:=2 to n do
begin
j:=i;
while(j>1) and (tab[j-1].pole2>tab[j].pole2) do
begin
pom1:=tab[j].pole2;
pom:=tab[j].pole1;
tab[j].pole2:=tab[j-1].pole2;
tab[j].pole1:=tab[j-1].pole1;
tab[j-1].pole2:=pom1;
tab[j-1].pole1:=pom;
j:=j-1;
end;
end;
writeln('uporzadkowana tablica:');
for i:=1 to n do
write(tab[i].pole1,' ',tab[i].pole2);
read(j);
end.