Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 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
|
||||
78
Task/Stack/Action-/stack-2.action
Normal file
78
Task/Stack/Action-/stack-2.action
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
CARD EndProg ;required for ALLOCATE.ACT
|
||||
|
||||
INCLUDE "D2:ALLOCATE.ACT" ;from the Action! Tool Kit. You must type 'SET EndProg=*' from the monitor after compiling, but before running this program!
|
||||
|
||||
DEFINE PTR="CARD"
|
||||
DEFINE NODE_SIZE="3"
|
||||
TYPE StackNode=[BYTE data PTR nxt]
|
||||
|
||||
StackNode POINTER stack
|
||||
|
||||
BYTE FUNC IsEmpty()
|
||||
IF stack=0 THEN
|
||||
RETURN (1)
|
||||
FI
|
||||
RETURN (0)
|
||||
|
||||
PROC Push(BYTE v)
|
||||
StackNode POINTER node
|
||||
|
||||
node=Alloc(NODE_SIZE)
|
||||
node.data=v
|
||||
node.nxt=stack
|
||||
stack=node
|
||||
RETURN
|
||||
|
||||
BYTE FUNC Pop()
|
||||
StackNode POINTER node
|
||||
BYTE v
|
||||
|
||||
IF IsEmpty() THEN
|
||||
PrintE("Error stack is empty!")
|
||||
Break()
|
||||
FI
|
||||
|
||||
node=stack
|
||||
v=node.data
|
||||
stack=node.nxt
|
||||
Free(node,NODE_SIZE)
|
||||
RETURN (v)
|
||||
|
||||
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()
|
||||
AllocInit(0)
|
||||
stack=0
|
||||
|
||||
Put(125) PutE() ;clear screen
|
||||
|
||||
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