September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
23
Task/Stack/Free-Pascal/stack.free
Normal file
23
Task/Stack/Free-Pascal/stack.free
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
program Stack;
|
||||
{$IFDEF FPC}{$MODE DELPHI}{$IFDEF WINDOWS}{$APPTYPE CONSOLE}{$ENDIF}{$ENDIF}
|
||||
{$ASSERTIONS ON}
|
||||
uses Generics.Collections;
|
||||
|
||||
var
|
||||
lStack: TStack<Integer>;
|
||||
begin
|
||||
lStack := TStack<Integer>.Create;
|
||||
try
|
||||
lStack.Push(1);
|
||||
lStack.Push(2);
|
||||
lStack.Push(3);
|
||||
Assert(lStack.Peek = 3); // 3 should be at the top of the stack
|
||||
|
||||
Write(lStack.Pop:2); // 3
|
||||
Write(lStack.Pop:2); // 2
|
||||
Writeln(lStack.Pop:2); // 1
|
||||
Assert(lStack.Count = 0, 'Stack is not empty'); // should be empty
|
||||
finally
|
||||
lStack.Free;
|
||||
end;
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue