- , ', , .
:
- , - .

- ( , , , ). , , Lisp, Prolog, Logo.

[]

program QUEUE;
uses crt;
type
QuePtr=^QUE;
QUE=record
Member:string;
EndPtr:QuePtr;
End;
var
Cl,Head,Tail:Pointer;
x,y:integer;
c:char;
Link:QuePtr;
Flag:boolean;
Number:Word;

procedure menu;
Begin
clrscr;
gotoxy(20,1); Writeln('I-ղ ;'); gotoxy(20,2);
Writeln('E-ղ ;'); gotoxy(20,3);
Writeln('V- ;'); gotoxy(20,4);
Writeln('ESC-ղ .'); gotoxy(3,6);
Write(' IJ ²²ί ²ز ');
End;{menu}

procedure PutInQueue(var Inp:string;var List:QuePtr);
var { }
Temp:Pointer;
Begin
New(List);
if (Head=Nil)and(Tail=Nil)
then
Begin
Head:=List; Tail:=List; List^.Member:=Inp;
End
else
Begin
List^.Member:=Inp; Temp:=List; List:=Tail;
List^.EndPtr:=Temp; Tail:=List^.EndPtr; List:=Tail;
End;
List^.EndPtr:=Nil;
End;{PutInQueue}
procedure InitQueue;{Ͳֲ˲ֲ}
Begin
Head:=Nil;Tail:=Nil; Number:=0;
End;
procedure CreateQueue(var I:Word;var List:QuePtr);
var
Ch:Char;
InpMem:String;
Begin
Ch:=' ';x:=5;y:=1;
while (ord(ch)<>27)and(MaxAvail>SizeOf(QUE)) do
Begin
clrscr; gotoxy(x,y); inc(i); write('' ',i,': ');
readln(InpMem); PutInQueue(InpMem,List); clrscr; gotoxy(1,3);
write(' ² ² ESC. ');
memw[0:$41a]:=memw[0:$41c]; ch:=readkey;
End;{while}
End;{CreateQueue}
procedure OutQueue(var Ch:char;var List:QuePtr);
Begin {ղ }
List:=Head; gotoxy(2,3); write('Head: ',List^.Member); memw[0:$41a]:=memw[0:$41c];
ch:=readkey;
If ord(Ch)<>27
then
Begin
Head:=List^.EndPtr; dec(Number); dispose(List);
End;
if Head=Nil
then
Tail:=Nil;
End;{OutQueue}
procedure OutFromQueue(var I:Word;var List:QuePtr);
var
Ch:char;
Begin
Ch:=' ';
while (Head<>NIL)AND(Tail<>NIL)AND(ord(Ch)<>27) do
Begin
clrscr; gotoxy(15,1); write('ʲʲ ʲ:',i); gotoxy(1,6);
write('ղ ² ² ESC. ');
OutQueue(Ch,List);
End;{WHILE}
IF (Head=NIL)AND(Tail=NIL)
THEN
Begin
clrscr; gotoxy(22,3); write(' .');
while ord(Ch)<>27 do
Begin
gotoxy(13,6); write(' - ² Esc.');
memw[0:$41a]:=memw[0:$41c]; Ch:=readkey;
End;
End;
End;{OutFromQueue}
procedure WriteQueue(var List:QuePtr);
var i:integer; { }
Begin
i:=1;
If (Head=Nil)and(Tail=Nil)
Then
Begin
gotoxy(30,12); write(' .');
End
else
Begin
List:=Head; gotoxy(1,1); write('Head: ');
while List<>Nil do
Begin
if (Wherex>70)and(Wherey = 20 )
then
Begin
writeln('. . .'); gotoxy(20,22); Write(' :');
memw[0:$41a]:=memw[0:$41c]; c:=readkey; ClrScr;gotoxy(1,1);write('Head: . . . ');
End;
Write(i,'.',List^.Member,' '); inc(i); List:=List^.EndPtr;
End;{WHILE}
write(' :Tail');
End;
while ord(c)<>27 do
Begin
gotoxy(23,23); write(' - ² Esc.'); memw[0:$41a]:=memw[0:$41c]; c:=readkey;
End;
End;

Begin
Clrscr;
InitQueue;
Mark(Cl);
Flag:=True;
menu;
while Flag do
Begin
memw[0:$41a]:=memw[0:$41c]; c:=readkey;
case c of
'I','i' :Begin
CreateQueue(Number,Link); menu;
End;
'E','e','','':Begin
OutFromQueue(Number,Link); menu;
End;
'V','v':Begin
WriteQueue(Link); menu;
End;
#27:Begin
Flag:=False;
End;
End;{case}
End;{while}
Release(Cl);
End.

[ ]

[ | | ]