home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
COMPUSCI
/
VCLANG11.ZIP
/
MONITOR.CLN
< prev
next >
Wrap
Text File
|
1990-08-17
|
821b
|
59 lines
program REVERSE;
const
TRUE = 1;
FALSE = 0;
var
x;
monitor STACKHANDLER;
var
TOP, STACK[20];
procedure UNDERFLOW;
begin
write('Stack empty')
end;
procedure OVERFLOW;
begin
write('Stack full')
end;
function *EMPTY;
begin
EMPTY := FALSE;
if TOP = 0 then EMPTY := TRUE
end;
procedure *PUSH(ITEM);
begin
TOP := TOP+1;
if TOP > 20 then OVERFLOW;
STACK[TOP] := ITEM
end;
function *POP;
begin
if TOP = 0 then UNDERFLOW;
POP := STACK[TOP];
TOP := TOP-1
end;
begin
TOP := 0
end;
begin
read(X);
while X > 0 do
begin STACKHANDLER.PUSH(X); read(X) end;
while STACKHANDLER.EMPTY = FALSE do write(STACKHANDLER.POP)
end.