Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
60
Task/Stack/Action-/stack-1.action
Normal file
60
Task/Stack/Action-/stack-1.action
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
DEFINE MAXSIZE="200"
|
||||
BYTE ARRAY stack(MAXSIZE)
|
||||
BYTE stacksize=[0]
|
||||
|
||||
BYTE FUNC IsEmpty()
|
||||
IF stacksize=0 THEN
|
||||
RETURN (1)
|
||||
FI
|
||||
RETURN (0)
|
||||
|
||||
PROC Push(BYTE v)
|
||||
IF stacksize=maxsize THEN
|
||||
PrintE("Error: stack is full!")
|
||||
Break()
|
||||
FI
|
||||
stack(stacksize)=v
|
||||
stacksize==+1
|
||||
RETURN
|
||||
|
||||
BYTE FUNC Pop()
|
||||
IF IsEmpty() THEN
|
||||
PrintE("Error: stack is empty!")
|
||||
Break()
|
||||
FI
|
||||
stacksize==-1
|
||||
RETURN (stack(stacksize))
|
||||
|
||||
PROC TestIsEmpty()
|
||||
IF IsEmpty() THEN
|
||||
PrintE("Stack is empty")
|
||||
ELSE
|
||||
PrintE("Stack is not empty")
|
||||
FI
|
||||
RETURN
|
||||
|
||||
PROC TestPush(BYTE v)
|
||||
PrintF("Push: %B%E",v)
|
||||
Push(v)
|
||||
RETURN
|
||||
|
||||
PROC TestPop()
|
||||
BYTE v
|
||||
|
||||
Print("Pop: ")
|
||||
v=Pop()
|
||||
PrintBE(v)
|
||||
RETURN
|
||||
|
||||
PROC Main()
|
||||
TestIsEmpty()
|
||||
TestPush(10)
|
||||
TestIsEmpty()
|
||||
TestPush(31)
|
||||
TestPop()
|
||||
TestIsEmpty()
|
||||
TestPush(5)
|
||||
TestPop()
|
||||
TestPop()
|
||||
TestPop()
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue