Pagini recente » Cod sursa (job #3283310) | Cod sursa (job #3226864) | Cod sursa (job #2542898) | Cod sursa (job #423136) | Cod sursa (job #43817)
Cod sursa(job #43817)
type pnod=^nod;
nod=record
x:integer;
leg:pnod;
end;
var f:text;
n,i,j,k:integer;
nou,p,aux:pnod;
begin
assign(f,'schi.in');
reset(f);
readln (f,n);
readln(f);
new(p);
p^.x:=1;
p^.leg:=nil;
for i:=2 to n do
begin
readln(f,j);
new(nou);
nou^.x:=i;
if j=1 then
begin
nou^.leg:=p;
p:=nou;
end
else
begin
aux:=p;
for k:=1 to j-2 do aux:=aux^.leg;
nou^.leg:=aux^.leg;
aux^.leg:=nou;
end;
end;
close(f);
assign(f,'schi.out'); rewrite(f);
while p<>nil do
begin
writeln(f,p^.x);
p:=p^.leg;
end;
close(f);
end.