program MyDoubleList; uses crt; type List= ^NOte; Note=record info:integer; right:List; left:List; end; var walk,V:list; command,x:byte; procedure ToCreate; begin walk:=nil; end; procedure ToAdd(var walk:list;x:integer); var temp:list; begin new(temp); temp^.info:=x; if walk=nil then begin walk:=temp; walk^.right:=nil; walk^.left:=nil; end else begin if walk^.right=nil then temp^.right:=nil else begin temp^.right:=walk^.right; walk^.right^.left:=temp; end; walk^.right:=temp; temp^.left:=walk; end; end; procedure ToDelete(var walk:list; x:integer); var temp,extra:list; begin if walk=nil then begin writeln('Cnucok nycT'); readln; end; if (walk^.right=nil) and (walk^.left=nil) then if walk^.info=x then begin dispose(walk); walk:=nil; end else halt; temp:=walk; while (temp^.info<>x) and (temp^.right<>nil) do temp:=temp^.right; begin extra:=temp^.right; temp^.right:=extra^.right; dispose(extra); end; end; function ToSearch(walk:list; x:integer):list; begin if walk<>nil then begin while (walk<>nil) and (walk^.info<>x) do walk:=walk^.right; if walk^.info<>x then ToSearch:=nil else ToSearch:=walk; end else begin ToSearch:=nil; end; end; function ToLength(walk:list): byte; var temp:list; i:byte; begin temp:=walk; i:=0; while temp<>nil do begin i:=i+1; temp:=temp^.right; end; ToLength:=i; end; procedure ToPrint(walk:list); begin if walk=nil then writeln ('Cnucok nycT!!!') else write ('<'); while walk<>nil do begin write(walk^.info); if walk^.right<>nil then write(','); walk:=walk^.right; end; write('>'); readkey; end; procedure ToListClear(walk:list); var temp:list; begin while walk<>nil do begin temp:=walk; walk:=walk^.right; dispose(temp); end; end; begin repeat TextBackGround(9); ClrScr; TextColor(12); GotoXY(20,4); writeln('|--------------------[ MENU ]-----------------|'); GOtoxy(20,5); writeln('| 1. CozdaHue cnucka |'); GotoXy(20,6); writeln('| 2. DobaBuT element |'); GotoXY(20,7); writeln('| 3. HauTu agpec elemenTa no HOMEPY |'); GotoXY(20,8);writeln ('| 4. YdaluT element |'); GotoXY(20,9);writeln ('| 5. Onpedelenue dlinu cnucka |'); GotoXY(20,10);writeln('| 6.BuBod na moHuTop |'); GotoXY(20,11);writeln('| 7.OchucTuT cnucok |'); GotoXY(20,12);writeln('| 8.EXIT |'); GotoXy(20,13);writeln('|---------------------------------------------|'); GotoXY(20,19); TextBackGround(9); TextColor(15); write('Enter 1, 2, 3 ,4 ,5 ,6 ,7 ,8 : '); Readln(command); writeln; case command of 1: begin ToCreate; writeln('Cnucok cozdaH'); end; 2: begin writeln('BBeduTe Homep'); readln(x); ToAdd(walk,x); end; 3: begin writeln('BBeduTe Homep'); readln(x); V:=ToSearch(walk,x); writeln(^V); readln; end; 4: begin writeln('BBeduTe Homep'); readln(x); ToDelete(walk,x); end; 5: begin writeln('DluHA : ', ToLength(walk)); repeat until keypressed; end; 6: begin ToPrint(walk); writeln; end; 7: begin ToListClear(walk); walk:=nil; end; 8: begin TextColor(4); writeln('**********Special thanks to Eugene:-)**********'); readln; end; else begin TextColor(4); writeln(' Wrong symbol!!!'); readln; end; end; until command=8; end.