|
|
back to boardcrash acess violation #1 WHY? type hlist=^list; list=record data: longint; l,r: hlist; end; var n,i:longint; a:array[1..3000] of longint; head: hlist; procedure add(var v:hlist; x:longint); begin if v=nil then begin new(v); v^.data:=x; end else if x>v^.data then add(v^.r, x) else add(v^.l, x); end; procedure draw(var v:hlist); begin if not (v=nil) then begin draw(v^.r); draw(v^.l); write(v^.data,' '); dispose(v); end; end; begin readln(n); for i:=n downto 1 do read(a[i]); for i:=1 to n do add(head, a[i]); draw(head); end. Re: crash acess violation #1 The same error! I don't understand why and what does mean acess violation? Help, please! program p1136; type arbore=^nod; nod=record info:word; left,right:arbore; end; var t,r,q:arbore; n,i:integer; a:array [1..3000] of word; procedure postordine(t:arbore); begin if t<>nil then begin postordine(t^.right); postordine(t^.left); write(t^.info,' '); end; end; begin readln(n); for i:=n downto 1 do read(a[i]); new(t);new(q);new(r);t^.info:=a[1]; for i:=2 to n do begin r:=t; while q<>nil do begin if a[i]>r^.info then begin new(q);q:=r^.right;end else begin new(q);q:=r^.left;end; if q<>nil then r:=q; end; new(q);q^.info:=a[i]; if r^.info<a[i] then r^.right:=q else r^.left:=q; end; postordine(t); end. |
|
|