uses crt;
var
a:array [1..5,1..6] of integer;
i,j,max,imax,c,d,s:integer;
f:byte;
begin
randomize;
f:=0;
s:=0;
repeat
clrscr;
writeln('ИСХОДНЫЙ МАССИВ:');
for i:=1 to 5 do
begin
for j:=1 to 6 do
begin
a[i,j]:=random(10);
write(a[i,j]:3);
end;
writeln;
end;
writeln('ВВЕДИТЕ ИНТЕРВАЛ ПОИСКА:');
write('c:');
readln(c);
write('d:');
readln(d);
if (d>c) then f:=1;
until f=1;
writeln('НОМЕРА МАКСИМАЛЬНЫХ ЭЛЕМЕНТОВ СТРОК:');
for i:=1 to 5 do
begin
max:=a[i,1];
imax:=1;
for j:=2 to 6 do
if a[i,j]>max then
begin
max:=a[i,j];
imax:=j;
end;
write(imax:3);
end;
for i:=1 to 5 do
for j:=1 to 6 do
if (a[i,j]>=c)and(a[i,j]<=d) then s:=s+a[i,j];
writeln;
writeln('СУММА ЭЛЕМЕНТОВ ПРИНАДЛ. [',c,',',d,'] РАВНА ',s);
readln;
end.