Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
29
Task/Stack/XPL0/stack.xpl0
Normal file
29
Task/Stack/XPL0/stack.xpl0
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
include c:\cxpl\codes; \intrinsic 'code' declarations
|
||||
int Stack(100), SP;
|
||||
|
||||
proc Push(I); \Push an integer onto the Stack
|
||||
int I;
|
||||
[SP:= SP+1;
|
||||
Stack(SP):= I;
|
||||
]; \Push
|
||||
|
||||
func Pop; \Pop an integer from the Stack
|
||||
int I;
|
||||
[I:= Stack(SP);
|
||||
SP:= SP-1;
|
||||
return I;
|
||||
]; \Pop
|
||||
|
||||
func Empty; \Return 'true' if Stack is empty
|
||||
return SP<0;
|
||||
|
||||
func Top; \Return the integer at top of Stack
|
||||
return Stack(SP);
|
||||
|
||||
int I;
|
||||
[SP:= -1; \initialize stack pointer
|
||||
for I:= 0 to 10 do Push(I*I);
|
||||
IntOut(0, Top); CrLf(0);
|
||||
while not Empty do [IntOut(0, Pop); ChOut(0, ^ )];
|
||||
CrLf(0);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue