all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
21
Task/Stack/Elisa/stack-1.elisa
Normal file
21
Task/Stack/Elisa/stack-1.elisa
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
component GenericStack ( Stack, Element );
|
||||
type Stack;
|
||||
Stack (MaxSize = integer) -> Stack;
|
||||
Empty ( Stack ) -> boolean;
|
||||
Full ( Stack ) -> boolean;
|
||||
Push ( Stack, Element) -> nothing;
|
||||
Pull ( Stack ) -> Element;
|
||||
begin
|
||||
Stack(MaxSize) =
|
||||
Stack:[ MaxSize; index:=0; area=array (Element, MaxSize) ];
|
||||
Empty( stack ) = (stack.index <= 0);
|
||||
Full ( stack ) = (stack.index >= stack.MaxSize);
|
||||
Push ( stack, element ) =
|
||||
[ exception (Full (stack), "Stack Overflow");
|
||||
stack.index:=stack.index + 1;
|
||||
stack.area[stack.index]:=element ];
|
||||
Pull ( stack ) =
|
||||
[ exception (Empty (stack), "Stack Underflow");
|
||||
stack.index:=stack.index - 1;
|
||||
stack.area[stack.index + 1] ];
|
||||
end component GenericStack;
|
||||
Loading…
Add table
Add a link
Reference in a new issue