stackadt

stackadt - WriteLn; ELSE INC (s.top); s.storage[s.top] :=...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
IMPLEMENTATION MODULE stackadt; FROM InOut IMPORT WriteString, WriteLn; FROM elements IMPORT elementtype; PROCEDURE define (VAR s : stack); BEGIN s.top := 0 END define; PROCEDURE makempty (VAR s : stack); BEGIN s.top := 0 END makempty; PROCEDURE empty (s : stack): BOOLEAN; BEGIN RETURN s.top = 0 END empty; PROCEDURE stackfull (s : stack): BOOLEAN; BEGIN RETURN s.top = 10 END stackfull; PROCEDURE push (VAR s : stack; item: elementtype); BEGIN IF stackfull (s) THEN WriteLn; WriteLn; WriteString ("stackoverflow"); WriteLn;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: WriteLn; ELSE INC (s.top); s.storage[s.top] := item; END; END push; PROCEDURE pop (VAR s : stack; VAR item: elementtype); BEGIN IF empty (s) THEN WriteLn; WriteLn; WriteString ("stackunderflow"); WriteLn; WriteLn; ELSE item:= s.storage[s.top]; DEC (s.top); END; END pop; PROCEDURE topstack (s : stack): elementtype; BEGIN IF empty (s) THEN WriteLn; WriteLn; WriteString ("stackunderflow"); WriteLn; WriteLn; ELSE RETURN s.storage[s.top]; END; END topstack; END stackadt....
View Full Document

Page1 / 2

stackadt - WriteLn; ELSE INC (s.top); s.storage[s.top] :=...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online