Смекни!
smekni.com

Основы программирования (стр. 2 из 2)

program DODAVANNYA;

uses Dinamo, Crt;

type

pdata=^tdata;

tdata=record

a:string[20];

end;

var

r: char;

dont,first,ptemp: pitem;

b:string[20];

tmp :pdata;

Procedure Novoe;far;

begin

new(tmp);

writeln('Vvedite zifru');

read(b);

if first=nil then

begin

with tmp^ do a:=b;

dont:=new_item(tmp);

first:=new_item(tmp);

end

else

begin

with tmp^ do a:=b;

dont:=make_item(dont,tmp);

end;

end;

Procedure Print(p:pointer);far;

begin

with pdata(p)^ do

begin

writeln(a);

writeln('<>< <>< <><');

end;

repeat

r:=readkey;

until r in [#32]

end;

Function test(p:pointer):boolean;far;

var t : boolean;

begin

with pdata(p)^ do t:=a=b;

end;

Procedure ToBeFound;far;

begin

new(tmp);

writeln('What must I to find?');

read(b);

Find(first,test,Print);

repeat

until keypressed;

end;

Procedure Vstav;far;

begin

new(tmp);

writeln('Posle chego?');

read(b);

if b = 'h' then

begin

writeln('Chto?');

readln(b);

with tmp^ do a:=b;

first:=Insert_head(first,tmp);

end

else

begin

ptemp:=Find(first,test,Print);

if ptemp<>nil then

begin

writeln('Chto?');

readln(b);

with tmp^ do a:=b;

Insert(ptemp,test,tmp);{Type mismatch}

end;

if ptemp=nil then

begin

writeln('Chto?');

readln(b);

with tmp^ do a:=b;

dont:=new_item(tmp);

end;

end;

end;

begin {programmka}

first:=nil;

repeat

{clrscr;}

writeln('(С)оздавать, (П)росмотр, (У)даление, По(и)ск, (B)ставка');

repeat

r:=readkey;

until r in ['c', 'g','b','d','e', #27];

case r of

'c' : Novoe;

'g' : Prosm(first,Print);

'b' : ToBeFound;

'd' : Vstav;

{'e' : Delet; }

end;

until r=#27;

dispose(tmp);

end.