新手,NOIP2012一道题不会,求教一下
pascal吧
全部回复
仅看楼主
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
level 11
这个题是普及组的吗
2014年10月12日 01点10分 2
level 1
var
n, i, temp, sum : integer;
a : array[1..100] of integer;
begin
readln(n); [n=8]
for i := 1 to n do
read(a[i]); {a[1]=40 a[2]=70 a[3]=50 a[4]=70 a[5]=20 a[6]=40 a[7]=10 a[8]=30}
for i := 1 to n - 1 do
if a[i] > a[i + 1] then
{a[1]=40 a[2]=50 a[3]=70 a[4]=20 a[5]=40 a[6]=10 a[7 ]=30 a[8]=70 }
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 { a[1]=10 a[2]=40 a[3]=50 a[4]=70 a[5]=20 a[6]=40 a[7]=30 a[8]=70 }
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]); {sum=250}
writeln(sum div (n - 2)); {sum=41}
end.
输入:
8 40 70 50 70 20 40 10 30
输出:
______41___
2014年10月12日 01点10分 3
下午就考试了 求好运
2014年10月12日 01点10分
1