Program IntStack(Output, Infile, Outfile); Type ListType = ^RecType; RecType = Record Num:Integer; Next:ListType; End; Var Infile, Outfile:Text; Num:Integer; List:ListType; Procedure Push(Var List:ListType; Num:Integer); Var P:ListType; Begin {Push} P := New(ListType); P^.Num := Num; P^.Next := List; List := P; End; {Push} Function Empty(List:ListType):Boolean; Begin {Empty} Empty := List = NIL End; {Empty} Procedure Pop(Var List:ListType; Var Num:Integer); Var P:ListType; Begin {Pop} If Not Empty(List) Then Begin P := List; Num := P^.Num; List := List^.Next; Dispose (P); End End; {Pop} Procedure PrintList(List:ListType); Var Num:Integer; Begin {PrintList} While Not Empty(List) Do Begin Pop(List, Num); Writeln(Outfile, Num); End; End; {PrintList} Begin {IntStack} Assign(Infile, 'c:\NumStack.txt'); Reset(Infile); Assign(Outfile, 'c:\Report.txt'); Rewrite(Outfile); List := NIL; Writeln(Outfile, 'As Read'); While Not EOF(Infile) Do Begin Readln(Infile, Num); Writeln(Outfile, Num); Push(List, Num); End; Writeln(Outfile); Writeln(Outfile, 'From stack'); PrintList(List); Close(Outfile); End. {IntStack}