Pascal
const
n = 5;
var
a : array [1..n] of integer;
b,m,ib,im : integer;
i : integer;
k : integer;
sr : real;
begin
a[1] := 5; a[2] := 8;
a[3] := 7; a[4] := 6;
a[5] := 10;
b := a[1]; m := a[1];
ib := 1; im := 1;
for i := 2 to n do
if a[i] > b then
begin
b := a[i];
ib := i;
end
else
if a[i] < m then
begin
m := a[i];
im := i;
end;
sr := 0;
k := 0;
if ib > im then
for i := im +1 to ib -1 do
begin
sr := sr + a[i];
k := k +1;
end
else
for i := ib +1 to im -1 do
begin
sr := sr + a[i];
k := k +1;
end;
sr := sr/k;
writeln ();
for i := 1 to n do
write (a[i],' ');
writeln ();
writeln ('sr=',sr:3:3);
writeln ();
writeln ('max=',b,' index =',ib);
writeln ('min=',m,' index =',im);
end.