Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Const
- MaxSize = 1024;
- Type
- TListType = LongInt;
- TList = Record
- Size : Word;
- Nodes : Array [0 .. MaxSize] Of TListType;
- End;
- PListType = ^TListType;
- Var
- A : TList;
- Procedure InitList(Var List : TList);
- Begin
- List.Size := 0;
- End;
- Procedure AppendElement(Var List : TList; Element : TListType);
- Begin
- List.Nodes[List.Size] := Element;
- Inc(List.Size);
- End;
- Function PopElement(Var List : TList) : PListType;
- Begin
- Dec(List.Size);
- PopElement := Addr(List.Nodes[List.Size]);
- End;
- Procedure RemoveAt(Var List : TList; Pos : Word);
- Begin
- Dec(List.Size);
- For Pos := Pos To List.Size - 1 Do
- List.Nodes[Pos] := List.Nodes[Pos + 1];
- End;
- Procedure PrintList(Var List : TList);
- Var
- I : LongInt;
- Begin
- WriteLn('List size: ', List.Size);
- For I := 0 To LongInt(List.Size) - 1 Do
- Write(List.Nodes[I], ' ');
- WriteLn;
- End;
- Begin
- InitList(A);
- AppendElement(A, 1);
- AppendElement(A, 2);
- AppendElement(A, 3);
- AppendElement(A, 4);
- PrintList(A);
- WriteLn(PopElement(A)^);
- RemoveAt(A, 1);
- PrintList(A);
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement