Program spusku;
uses crt;
type
spusok=^elem;
elem=record
data:integer;
next:spusok;
end;
var i:spusok;
procedure add(var current:spusok; elem:integer);
var x:spisok;
begin
new(x);
x^.data:=elem;
x^.next:=nil;
current^.next:=x;
current:=x;
end;
procedure stvor(var i:spusok);
var p:spisok; n:integer;
begin
i:=nil;
writeln('Vvedite spusok celux 4usel. 0-konec');
readln(n);
add(i,n);
readln(n);
while n<>0 do
begin
p:=i;
while p^.next<>nil do
p:=p^.next;
add(p,n);
readln(n);
end;
end;
procedure minmax(var i:spusok);
var p:spusok; kmin, kmax:integer;
begin
kmin:=1000000;
kmax:=0;
while i<>nil do
begin
p:=i;
if p^.data>kmax then kmax:=p^.data;
if p^.data i:=i^.next;
end;
writeln('raznost =', kmax-kmin)
end;
BEGIN
clrscr;
stvor(i);
minmax(i);
readkey;
end.