level 1
轩汪
楼主
var
n, i, temp, sum : integer;
a : array[1..100] of integer;
begin
readln(n);
for i := 1 to n do
read(a[i]);
for i := 1 to n - 1 do
if a[i] > a[i + 1] then
begin
temp := a[i];
a[i] := a[i + 1];
a[i + 1] := temp;
end;
for i := n downto 2 do
if a[i] < a[i - 1] then
begin
temp := a[i];
a[i] := a[i - 1];
a[i - 1] := temp;
end;
sum := 0;
for i := 2 to n - 1 do
inc(sum, a[i]);
writeln(sum div (n - 2));
end.
输入:
8
40 70 50 70 20 40 10 30
输出:
_________
2014年10月11日 13点10分
1
n, i, temp, sum : integer;
a : array[1..100] of integer;
begin
readln(n);
for i := 1 to n do
read(a[i]);
for i := 1 to n - 1 do
if a[i] > a[i + 1] then
begin
temp := a[i];
a[i] := a[i + 1];
a[i + 1] := temp;
end;
for i := n downto 2 do
if a[i] < a[i - 1] then
begin
temp := a[i];
a[i] := a[i - 1];
a[i - 1] := temp;
end;
sum := 0;
for i := 2 to n - 1 do
inc(sum, a[i]);
writeln(sum div (n - 2));
end.
输入:
8
40 70 50 70 20 40 10 30
输出:
_________