Category : Pascal Source Code
Archive   : T-SORTS.ZIP
Filename : QUEUE.PAS

 
Output of file : QUEUE.PAS contained in archive : T-SORTS.ZIP

Program Queue(input,output);


{ Queue program by Chris Gorman of 2AM Associates.
If you have comments of questions you can reach Chris at the original
2AM-BBS, the DREW UNIVERSITY UNDERGROUND. (201)-377-8245 }


Type nodeptr=^node;
node=record
data:integer;
next:nodeptr;
end;

Var queue:nodeptr;
i,x:integer;

Procedure push(Var Q:nodeptr;x:integer);
Var P,s:nodeptr;
begin
new(p);
p^.data:=x;
P^.next:=nil;
s:=Q;
If (q=nil) {empty queue} then Q:=p else begin
While (s^.next<>nil) do s:=s^.next;
s^.next:=p;
end;
end;


Function pop(Var q:nodeptr):integer;
Var s:nodeptr;
begin
s:=q;
pop:=q^.data;
q:=q^.next;
dispose(s);
end;

begin
Queue:=nil;
For i:=1 to 4 do begin
writeln('enter number');
readln(x);
push(queue,x);
end;
For I:=1 to 4 do writeln(pop(queue));
end.


  3 Responses to “Category : Pascal Source Code
Archive   : T-SORTS.ZIP
Filename : QUEUE.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/