Pagini recente » Cod sursa (job #1134971) | Cod sursa (job #2287628) | Cod sursa (job #834101) | Cod sursa (job #1321821) | Cod sursa (job #36678)
Cod sursa(job #36678)
program schi;
type arbore=^nod;
nod=record
id,loc:longint;
st,dr:arbore;
end;
var r:arbore;
f,g:text;
n:longint;
procedure mar1(r:arbore);
begin
if r<>nil then
begin
inc(r^.loc);
mar1(r^.st);
mar1(r^.dr);
end;
end;
procedure create(var r:arbore;x,y:longint);
begin
if r=nil then
begin
new(r);
r^.id:=x;
r^.loc:=y;
r^.st:=nil;
r^.dr:=nil;
end else
if y<=r^.loc then
begin
inc(r^.loc);
mar1(r^.dr);
create(r^.st,x,y);
end else
create(r^.dr,x,y);
end;
procedure iofile;
var i,x:longint;
begin
assign(f,'schi.in');
reset(f);
assign(g,'schi.out');
rewrite(g);
readln(f,n);
r:=nil;
for i:=1 to n do
begin
readln(f,x);
create(r,i,x);
end;
close(f);
end;
procedure srd(r:arbore);
begin
if r<>nil then
begin
srd(r^.st);
writeln(g,r^.id);
srd(r^.dr);
end;
end;
begin
iofile;
srd(r);
close(g);
end.