(*Ukazatele*) (*Linearni seznam*) Uses Crt,Knihovna; Var R:integer;S2:String; PZ:integer; Type Ukaz=^Seznam; Seznam=record Minuly:Ukaz; Hodnota:String; Dalsi:Ukaz; End; Var Hodnoty:^Seznam; Min,Q,W,T:pointer; (**) Procedure Pridej(X:string); Begin New(Hodnoty); With Hodnoty^ Do begin Minuly:=Min; Hodnota:=X; Dalsi:=Nil; End; Min:=Hodnoty; Hodnoty^.Minuly^.Dalsi:=Min; End; (**) Procedure Vypis(QQ:integer); Var i:integer;S:string; Begin Barva(7,0);ClrScr;T:=Hodnoty; VytvorRam(1,1,80,24,1); Locate(1,3,'Ì'+strings(78,'Í')+'¹'); Locate(3,5,strings(76,'Ä')); Locate(3,2,'Vypis linearniho seznamu:'); Locate(3,4,'Polozka seznamu');Locate(26,5,'Â'); Locate(28,4,'Predchudce');Locate(51,5,'Â'); Locate(53,4,'Nasledovnik'); For i:=6 to 23 do Begin Locate(26,i,'³');Locate(51,i,'³');End; i:=6; Repeat W:=Hodnoty^.Minuly; Q:=Hodnoty^.Dalsi; if (i-6=QQ) then Begin Barva(11,4); Locate(2,i,Strings(24,' ')+'³'+strings(24,' ')+'³'+strings(28,' ')); End else Barva(7,0); GotoXY(3,i);Write(Hodnoty^.Hodnota); Hodnoty:=Q;GotoXY(53,i); If Q<>Nil then Write(Hodnoty^.Hodnota) else Writeln('------'); Hodnoty:=W;GotoXY(28,i); If W<>Nil then Writeln(Hodnoty^.Hodnota) else Writeln('------'); i:=i+1; Until W=Nil;i:=i-6; Barva(7,0); If i=1 then S:='zaznam' else If i<=4 then S:='zaznamy' else S:='zaznamu'; GotoXY(29,2);Writeln(i,' ',S);Hodnoty:=T; PZ:=i; End; (**) Procedure VlozMezi; Var s:string; a,b:integer; C,D,E:pointer; Begin Clrscr; Write('Zadejte text nove polozky: ');Readln(s); write('Zadejte poradi umisteni: ');readln(a); if (a>=2) and (a<=PZ) Then Begin Hodnoty:=Min; For b:=PZ downto a+1 do begin C:=Hodnoty^.Minuly; Hodnoty:=C; end; E:=Hodnoty^.Minuly; New(Hodnoty); Hodnoty^.Hodnota:=S; Hodnoty^.Dalsi:=C; Hodnoty^.Minuly:=E; D:=Hodnoty; Hodnoty:=E; Hodnoty^.Dalsi:=D; Hodnoty:=C; Hodnoty^.Minuly:=D; Hodnoty:=Min; Vypis(-1); End; End; (**) Procedure Najdi; Var S:string; i:integer; Label p; Begin ClrScr; i:=1; Write('Zadejte hledanou polozku: ');Readln(s); T:=Hodnoty; writeln(Hodnoty^.Hodnota); While Hodnoty^.Hodnota<>S do Begin i:=i+1; W:=Hodnoty^.Minuly; if W<>nil then Hodnoty:=W else begin i:=-1;goto p;End; writeln(Hodnoty^.Hodnota); End; p: Hodnoty:=T; Vypis(i-1); End; (**) Begin Barva(7,0);ClrScr; Min:=Nil; Pridej('Radek 1'); Pridej('Radek 2'); Pridej('Radek 3'); Pridej('Radek 4'); Vypis(-1); Repeat R:=Ord(Readkey); Case R of 97:Begin ClrScr; Write('Zadejte text nove polozky: '); Readln(S2); Pridej(S2); Vypis(-1); End; 98:VlozMezi; 110:Najdi; End; Until R=27; End.