{Moodul sisaldab 4 protseduuri, mida tavaliselt pinuga opereerimisel vaja l„heb. Pinu realiseeritakse staatiliselt (massiivi kasutades)} unit Pinustat; Interface const MaxStackSize=50; type infotyyp = real; {infotyypi tuleb vajaduse korral muuta} pinutyyp = record element: array[1..MaxStackSize] of infotyyp; Tipp: 0..MaxStackSize; 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=0; end; procedure Create(var top: pinutyyp); {Uue pinu tegemine. Pinu tipu v„„rtuseks saab Nil.} begin top.tipp:=0; 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.} begin with top do begin tipp := tipp+1; element[tipp] := info; end; 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).} begin with top do begin info := element[tipp]; tipp := tipp-1; end; end; begin end.