|
Politica de confidentialitate |
|
• domnisoara hus • legume • istoria unui galban • metanol • recapitulare • profitul • caract • comentariu liric • radiolocatia • praslea cel voinic si merele da aur | |
Stiva LIFO (last in first out) - Pascal | ||||||
|
||||||
Def: Este o lista liniara simplu inlantuita de tip special in care
adaugarile sau scoaterile elementelor se fac la un singur capat numit varful
stivei. q1s6sb While c<>nil do begin Writeln(c^.elem); c := c^.adr; end; end; End; Procedure adaugare; Begin new(c); Write(‘introd. un elem: ’); readln(c^.elem); c^.adr := varf; varf := c; end; Procedure stergere; begin If varf = nil then Writeln(‘Nu avem ce sterge!’) else begin Writeln(‘Puteti sterge numai ‘,varf^.elem); c : = varf; varf := c^.adr; dispose(c); end; end ; Aprogram principalS BEGIN varf := nil; Repeat Writeln(‘Daca doriti creare apasati C’); Writeln(‘Daca doriti listare apasati L’); Writeln(‘Daca doriti adaugare apasati A’); Writeln(‘Daca doriti stergere apasati S’); Writeln(‘Daca doriti iesire apasati E’); Readln(raspuns) ; Case upcase(raspuns) of ‘C’ : creare; ‘L’ : listare; ‘A’:adaugare; ‘S’ : stergere else writeln(‘Nu exista operatie asociata!’); until upcase (raspuns) = ’E’; END. |
||||||
|
||||||
|
||||||
Copyright© 2005 - 2024 | Trimite document | Harta site | Adauga in favorite |
|