{Moodul sisaldab 4 protseduuri, mida tavaliselt pinuga opereerimisel vaja l„heb. Pinu realiseeritakse dnaamiliselt } unit Pinudyn; Interface type infotyyp = real; {infotyypi tuleb vajaduse korral muuta} pinutyyp = ^pinutype; pinutype = record element: infotyyp; Tipp: pinutyyp; end; function Empty(top: pinutyyp): boolean; procedure Create(var top: pinutyyp); procedure Push(info: infotyyp; var top: pinutyyp); procedure Pop(var info: infotyyp; var top: pinutyyp); Implementation function Empty(top: pinutyyp): boolean; {Kontroll, kas pinu on thi. Kui thi, siis tagastatakse true, kui mitte, siis false.} begin Empty := top^.tipp=nil; end; procedure Create(var top: pinutyyp); {Uue pinu tegemine. Pinu tipu v„„rtuseks saab Nil.} begin new(top); top^.tipp:=nil; end; procedure push(info: infotyyp; var top: pinutyyp); {Uue elemendi lisamine pinu tippu Eeldus: pinu on olemas, pinus on ruumi. Elemendi infov„lja lisatakse info. Tagastatakse uus tipu aadress.} var node:pinutyyp; begin new(node); node^.element:=info; node^.tipp:=top; top:=node; end; procedure pop(var info: infotyyp; var top: pinutyyp); {Pinu tipmise elemendi eemaldamine. Tipus olnud info saab protseduurist k„tte parameetri info kaudu. Eeldus: pinus on elemente (seda porotseduur ei kontrolli).} var node:pinutyyp; begin info := top^.element; node:=top; top:=top^.tipp; dispose(node); end; begin end.