program nikos(input,output); uses crt; type pp=^re; re=record i,j:integer; u,d,l,r:pp; end; ar=array[1..30] of pp; var h,aux,temp:pp; ver,hor,vert,hort:ar; o,m,n,w:integer; c:char; procedure insert(var a,at:ar;f:integer); begin if f=1 then begin aux:=a[temp^.i]; while aux^.jm) do aux:=aux^.r; aux^.l^.r:=aux^.r; aux^.r^.l:=aux^.l; end; if f=2 then begin aux:=a[m]^.d; while (aux^.i<>o)do begin aux:=aux^.d; end; temp:=aux; aux^.u^.d:=aux^.d; aux^.d^.u:=aux^.u; dispose(temp); end; end; procedure print(a,at:ar); begin for o:=1 to 30 do begin aux:=a[o]^.r; for m:=1 to 30 do if aux^.j<>31 then begin write('(',aux^.i,',',aux^.j,')'); aux:=aux^.r; end; end; writeln; end; begin clrscr; for m:=1 to 30 do begin new(ver[m]); new(vert[m]); new(hor[m]); new(hort[m]); ver[m]^.j:=0; vert[m]^.j:=31; hor[m]^.i:=0; hort[m]^.i:=31; ver[m]^.r:=vert[m]; vert[m]^.l:=ver[m]; hor[m]^.d:=hort[m]; hort[m]^.u:=hor[m]; ver[m]^.i:=m; vert[m]^.i:=m; hor[m]^.j:=m; hort[m]^.j:=m; vert[m]^.r:=nil; hort[m]^.d:=nil; end; c:=' '; while(c<>'q') do begin write('nsert elete

rint uit :'); readln(c); if c='i' then begin new(temp); repeat write('give i:'); readln(temp^.i); write('gibe j:'); readln(temp^.j); until (temp^.i>=1) and (temp^.i<=30) and (temp^.j>=1) and (temp^.j<=30); insert(ver,vert,1); insert(hor,hort,2); c:=' '; end; if c='p' then begin print(ver,vert); c:=' '; end; if c='d' then begin repeat write('give i that you want to delete :'); readln(o); write('give j that you want to delete :'); readln(m); until (o>=1) and (o<=30) and (m>=1) and (m<=30); delete(ver,vert,1); delete(hor,hort,2); c:=' '; end; end; end.