home *** CD-ROM | disk | FTP | other *** search
- Program StackDemo;
-
- Uses Stacks;
-
- Const
- Num = 10;
-
- Var
- A,B : RealStack;
- I : Word;
- R : Real;
-
- Begin
- A.Create;
- B.Create; { First,Last and ONLY call to CREATE for A or B! }
-
- WriteLn ('Both Stacks A and B are (Currently) sized at ',A.MaxSize,' Elements');
- A.Init (Num);
- WriteLn ('After A.Init, A now can hold ',A.MaxSize,' Elements');
-
- For I := 1 to Num do
- Begin
- A.Push (I*I*I*I); {Word is upwardly compatible with Real}
- R := I*I*I*I;
- WriteLn (I,'th Element Pushed onto Stack A is ',R:4:4)
- End;
-
- WriteLn;
- A.ReSize (Num);
- Write ('After A.ReSize, A can now hold ',A.MaxSize,' Elements');
- ReadLn;
-
-
- For I := (Num+1) to (Num + Num) do
- Begin
- A.Push (I);
- R := I;
- WriteLn (I,'th Element Pushed onto Stack A is ',R:4:4)
- End;
-
- WriteLn ('Before B.Copy, B can hold ',B.MaxSize,' Elements');;
- B.Copy (A);
- Write ('After B.Copy, B now holds ',B.Depth,' Elements');
- ReadLn;
-
- For I := 1 to (Num + Num) do
- Begin
- B.Pop (R);
- WriteLn (I,'th Element Popped off of Stack B is ',R:4:4)
- End;
-
- Write ('Press Return to Continue ...');
- ReadLn;
-
- End.