home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / arrays / generics / flxarray / stakdemo.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1989-07-23  |  1.2 KB  |  56 lines

  1. Program StackDemo;
  2.  
  3. Uses Stacks;
  4.  
  5. Const
  6.   Num = 10;
  7.  
  8. Var
  9.   A,B : RealStack;
  10.   I   : Word;
  11.   R   : Real;
  12.  
  13. Begin
  14.   A.Create;
  15.   B.Create;  { First,Last and ONLY call to CREATE for A or B! }
  16.  
  17.   WriteLn ('Both Stacks A and B are (Currently) sized at ',A.MaxSize,' Elements');
  18.   A.Init (Num);
  19.   WriteLn ('After A.Init, A now can hold ',A.MaxSize,' Elements');
  20.  
  21.   For I := 1 to Num do
  22.     Begin
  23.       A.Push (I*I*I*I);  {Word is upwardly compatible with Real}
  24.       R := I*I*I*I;
  25.       WriteLn (I,'th Element Pushed onto Stack A is ',R:4:4)
  26.     End;
  27.  
  28.   WriteLn;
  29.   A.ReSize (Num);
  30.   Write ('After A.ReSize, A can now hold ',A.MaxSize,' Elements');
  31.   ReadLn;
  32.  
  33.  
  34.   For I := (Num+1) to (Num + Num) do
  35.     Begin
  36.       A.Push (I);
  37.       R := I;
  38.       WriteLn (I,'th Element Pushed onto Stack A is ',R:4:4)
  39.     End;
  40.  
  41.   WriteLn ('Before B.Copy, B can hold ',B.MaxSize,' Elements');;
  42.   B.Copy (A);
  43.   Write ('After B.Copy, B now holds ',B.Depth,' Elements');
  44.   ReadLn;
  45.  
  46.   For I := 1 to (Num + Num) do
  47.     Begin
  48.       B.Pop (R);
  49.       WriteLn (I,'th Element Popped off of Stack B is ',R:4:4)
  50.     End;
  51.  
  52.   Write ('Press Return to Continue ...');
  53.   ReadLn;
  54.  
  55. End.
  56.