uses crt;
const n=80;
var a:array[1..n] of integer;
i,nastupenych:byte;
koniec:boolean;
procedure generuj;
begin
randomize;
nastupenych:=random(80)+1;
for i:=1 to nastupenych do a[i]:=green;
for i:=nastupenych+1 to 80 do a[i]:=0;
end;
procedure vypis;
begin
clrscr;
for i:=1 to n do
begin
textcolor(a[i]);
if a[i]<>0 then write('');
end;
writeln;
end;
procedure vloz;
var x:byte;
begin
write('Zadaj kam sa ma trpaslicka zaradit (ak uz prisli vsetky, zadaj 0): ');
readln(x);
if x=0 then koniec:=true
else
if (x<=nastupenych+1) then
begin
for i:=nastupenych downto x do a[i+1]:=a[i];
a[x]:=red;
if nastupenych<80 then inc(nastupenych);
end;
end;
begin
clrscr;
koniec:=false;
generuj;
vypis;
repeat
textcolor(15);
vloz;
gotoxy(1,1);
vypis;
until (nastupenych=80) or koniec;
readln
end.
