program ArithmeticMean; var n, i, max, min: integer; sum, count: integer; arr: array of integer; begin write('Enter the number of elements: '); readln(n);
setlength(arr, n);
write('Enter the elements of the array: '); for i := 0 to n - 1 do begin read(arr[i]); end;
max := arr[0]; min := arr[0]; sum := 0; count := 0;
for i := 0 to n - 1 do begin if arr[i] > max then max := arr[i]; if arr[i] < min then min := arr[i]; end;
for i := 0 to n - 1 do begin if (arr[i] <> max) and (arr[i] <> min) then begin sum := sum + arr[i]; count := count + 1; end; end;
if count <> 0 then writeln('Arithmetic mean of elements excluding max and min values: ', sum / count) else writeln('All elements are equal to max or min'); end.
program ArithmeticMean;
var
n, i, max, min: integer;
sum, count: integer;
arr: array of integer;
begin
write('Enter the number of elements: ');
readln(n);
setlength(arr, n);
write('Enter the elements of the array: ');
for i := 0 to n - 1 do
begin
read(arr[i]);
end;
max := arr[0];
min := arr[0];
sum := 0;
count := 0;
for i := 0 to n - 1 do
begin
if arr[i] > max then
max := arr[i];
if arr[i] < min then
min := arr[i];
end;
for i := 0 to n - 1 do
begin
if (arr[i] <> max) and (arr[i] <> min) then
begin
sum := sum + arr[i];
count := count + 1;
end;
end;
if count <> 0 then
writeln('Arithmetic mean of elements excluding max and min values: ', sum / count)
else
writeln('All elements are equal to max or min');
end.