program sortowanie_przez_wstawianie;
uses crt;
const zakres=10;
var tablica :array[0..zakres]of integer;
i,j,k:integer;
temp:integer;
z1:text;
begin
assign(z1, 'dane.txt');
reset(z1);
for k:=1 to zakres do
readln(z1, tablica[k]);
close(z1);
textcolor(white);
writeln ('Program demonstruje sortowanie przez wstawianie');
for k:=1 to zakres do
write (tablica[k],', ');
writeln;
for i:=2 to zakres do
begin
temp:=tablica[i];
tablica[0]:= temp;
j:=i-1;
while (temp < tablica[j]) do
begin
tablica[j+1] := tablica[j];
j:=j-1;
end;
tablica [j+1] := temp;
for k:=1 to zakres do
begin
if k<i then
textcolor(yellow)
else
textcolor(white);
write (tablica[k],', ');
end;
writeln;
end;
textcolor(yellow);
for k:=1 to zakres do
write (tablica[k],', ');
readln;
end.
program sortowanie_przez_wstawianie;
uses crt;
const zakres=10;
var tablica :array[0..zakres]of integer;
i,j,k:integer;
temp:integer;
z1:text;
begin
assign(z1, 'dane.txt');
reset(z1);
for k:=1 to zakres do
readln(z1, tablica[k]);
close(z1);
textcolor(white);
writeln ('Program demonstruje sortowanie przez wstawianie');
for k:=1 to zakres do
write (tablica[k],', ');
writeln;
for i:=2 to zakres do
begin
temp:=tablica[i];
tablica[0]:= temp;
j:=i-1;
while (temp < tablica[j]) do
begin
tablica[j+1] := tablica[j];
j:=j-1;
end;
tablica [j+1] := temp;
for k:=1 to zakres do
begin
if k<i then
textcolor(yellow)
else
textcolor(white);
write (tablica[k],', ');
end;
writeln;
end;
textcolor(yellow);
for k:=1 to zakres do
write (tablica[k],', ');
readln;
end.