Program TheList; uses crt; type List= ^NOte; Note=record info:integer; next:List; end; var first:list; command,x,y,z:integer; procedure ToCreate; begin first:=nil; end; procedure ToAdd(var first:list; x:integer); var temp:list; begin new(temp); temp^.info:=x; temp^.next:=first; first:=temp; end; procedure ToInsert_after(first:list;x:integer); var temp:list; begin new(temp); temp^.info:=x; temp^.next:=first^.next; first^.next:=temp; end; procedure ToInsert_before(first:list;x:integer); var temp:list; begin new(temp); temp^.next:=first^.next; first^.next:=temp; temp^.info:=first^.info; first^.info:=x; end; function ToSearch( first:list; x:integer):list; begin if first<>nil then begin while (first<>nil) and (first^.info<>x) do first:=first^.next; if first^.info<>x then ToSearch:=nil else ToSearch:=first; end else begin ToSearch:=nil; end; end; function ToLength(var first:list):byte; var temp:list; i:byte; begin temp:=first; i:=0; while temp<>nil do begin i:=i+1; temp:=temp^.next; end; ToLength:=i; end; procedure ToDelete(var first:list; x:integer); var temp:list; extra:list; found:boolean; begin found:=false; if first<>nil then if first^.info=x then begin found:=true; temp:=first; first:=first^.next; dispose(temp) end else extra:=first; while not found and (extra^.next<>nil) do if extra^.next^.info=x then found:=true else extra:=extra^.next; if found then begin temp:=extra^.next; extra^.next:=temp^.next; dispose(temp); end; end; procedure ToPrint( first:list); begin if first=nil then writeln ('Cnucok nycT!!!') else write ('<'); while first<>nil do begin write(first^.info); if first^.next<>nil then write(','); first:=first^.next; end; write('>'); readkey; end; procedure ToListClear(first:list); var temp:list; begin while first<>nil do begin temp:=first; first:=first^.next; 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 ¹ |'); GotoXY(20,8);writeln('| 4. YdaluT element |'); GotoXY(20,9);writeln('| 5. BcTaBuT neped elemenTom |'); GotoXY(20,10);writeln('| 6. BcTaBuT nocle elemenTa |'); GotoXY(20,11);writeln('| 7. Onpedelenue dlinu cnucka |'); GotoXY(20,12);writeln('| 8.BuBod na moHuTop |'); GotoXY(20,13);writeln('| 9.OchucTuT cnucok |'); GotoXY(20,14);writeln('| 10.EXIT |'); GotoXy(20,15);writeln('|---------------------------------------------|'); GotoXY(20,19); TextBackGround(9); TextColor(15); write('Enter 1, 2, 3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 : '); Readln(command); writeln; case command of 1: begin ToCreate; writeln('Cnucok cozdaH'); end; 2: begin writeln('BBeduTe Homep'); readln(x); ToAdd(first,x); end; 3: begin writeln('BBeduTe Homep'); readln(x); ToSearch(first,x); end; 4: begin writeln('BBeduTe Homep'); readln(x); ToDelete(first,x); end; 5: begin if first=nil then begin new(first); writeln('BBeduTE Homep'); readln(y); first^.info:=y; first^.next:=nil; end else writeln('BBeduTe Homep'); readln(x); writeln('BBeduTe zHacheHue'); readln(z); ToInsert_before(ToSearch(first,x),z); end; 6: begin if first=nil then begin new(first); writeln('BBeduTE Homep'); readln(y); first^.info:=y; first^.next:=nil; end else writeln('BBeduTe Homep'); readln(x); writeln('BBeduTe zHacheHue'); readln(z); ToInsert_after(ToSearch(first,x),z); end; 7: begin writeln('DluHA : ', ToLength(first)); repeat until keypressed; end; 8: begin ToPrint(first); writeln; end; 9: begin ToListClear(first); first:=nil; end; 10: begin TextColor(4); writeln('**********Special thanks to Eugene:-)**********'); readln; end; else begin TextColor(4); writeln(' Wrong symbol!!!'); readln; end; end; until command=10; end.