Program IntQueue(Output, Infile, Outfile); Type ListType = ^RecType; RecType = Record Num:Integer; Next:ListType; End; QueueType = Record Front, Rear:ListType; End; Var Infile, Outfile:Text; Num:Integer; Queue:QueueType; Procedure Enqueue(Var Queue:QueueType; Num:Integer); Var P:ListType; Begin {Enqueue} P := New(ListType); P^.Num := Num; P^.Next := NIL; If Queue.Rear = NIL Then Begin Queue.Rear := P; Queue.Front := Queue.Rear; End Else Begin Queue.Rear^.Next := P; Queue.Rear := P; End; End; {Enqueue} Function Empty(Queue:QueueType):Boolean; Begin {Empty} Empty := Queue.Rear = NIL End; {Empty} Procedure Dequeue(Var Queue:QueueType; Var Num:Integer); Var P:ListType; Begin {Dequeue} If Not Empty(Queue) Then Begin P := Queue.Front; Num := P^.Num; Queue.Front := Queue.Front^.Next; Dispose (P); If Queue.Front = NIL Then Queue.Rear := NIL; End End; {Dequeue} Procedure PrintList(Queue:QueueType); Var Num:Integer; Begin {PrintList} While Not Empty(Queue) Do Begin DeQueue(Queue, Num); Writeln(Outfile, Num); End; End; {PrintList} Begin {IntQueue} Assign(Infile, 'c:\NumQueue.txt'); Reset(Infile); Assign(Outfile, 'c:\Report.txt'); Rewrite(Outfile); Queue.Front := NIL; Queue.Rear := NIL; Writeln(Outfile, 'As Read'); While Not EOF(Infile) Do Begin Readln(Infile, Num); Writeln(Outfile, Num); Enqueue(Queue, Num); End; Writeln(Outfile); Writeln(Outfile, 'From queue'); PrintList(Queue); Close(Outfile); End. {IntQueue}