Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
72
Task/Queue-Definition/Action-/queue-definition-1.action
Normal file
72
Task/Queue-Definition/Action-/queue-definition-1.action
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
DEFINE MAXSIZE="200"
|
||||
BYTE ARRAY queue(MAXSIZE)
|
||||
BYTE queueFront=[0],queueRear=[0]
|
||||
|
||||
BYTE FUNC IsEmpty()
|
||||
IF queueFront=queueRear THEN
|
||||
RETURN (1)
|
||||
FI
|
||||
RETURN (0)
|
||||
|
||||
PROC Push(BYTE v)
|
||||
BYTE rear
|
||||
|
||||
rear=queueRear+1
|
||||
IF rear=MAXSIZE THEN
|
||||
rear=0
|
||||
FI
|
||||
IF rear=queueFront THEN
|
||||
PrintE("Error: queue is full!")
|
||||
Break()
|
||||
FI
|
||||
queue(queueRear)=v
|
||||
queueRear=rear
|
||||
RETURN
|
||||
|
||||
BYTE FUNC Pop()
|
||||
BYTE v
|
||||
|
||||
IF IsEmpty() THEN
|
||||
PrintE("Error: queue is empty!")
|
||||
Break()
|
||||
FI
|
||||
v=queue(queueFront)
|
||||
queueFront==+1
|
||||
IF queueFront=MAXSIZE THEN
|
||||
queueFront=0
|
||||
FI
|
||||
RETURN (v)
|
||||
|
||||
PROC TestIsEmpty()
|
||||
IF IsEmpty() THEN
|
||||
PrintE("Queue is empty")
|
||||
ELSE
|
||||
PrintE("Queue 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