uses crt;
type fail=file of char;
procedure Vyvod(var f:fail;n,k:byte);
var a:char;
i:integer;
begin
writeln('Символы с ',n,' по ',k,':');
reset(f);
if filesize(f)<k then
begin
writeln('В файле нет ',k,' символов');
writeln;
close(f);
end
else
begin
for i:=n-1 to k-1 do
begin
seek(f,i);
read(f,a);
write(a,' ');
end;
writeln;
writeln;
close(f);
end;
end;
var f:fail;
a:char;
k,s:integer;
begin
clrscr;
assign(f,'file');
rewrite(f);
writeln('Введите в файл символы, окончание ввода 0:');
repeat
readln(a);
if a<>'0' then write(f,a);
until a='0';
writeln('Содержание исходного файла:');
reset(f);
while not eof(f) do
begin
read(f,a);
write(a,' ');
end;
writeln;
writeln;
close(f);
clrscr;
repeat
writeln('Введите диапазон номеров для вывода 0<k<s');
readln(k,s);
until(k>0)and(s>k);
writeln;
Vyvod(f,5,15);
Vyvod(f,3,20);
Vyvod(f,k,s);
readln
end.