搜索

pascal问题。高手请进,严禁刷屏+灌水

发布网友 发布时间:2024-10-23 19:20

我来回答

3个回答

热心网友 时间:2024-11-09 19:56

var n,s,t,i,max,min:longint;
begin
readln(n);min:=maxlongint;
for i:=1 to n do
begin
read(t);
inc(s,t);
if min>t then min:=t;
if max<t then max:=t;
end;
writeln((s-min-max)/(n-2):0:2);
end.

热心网友 时间:2024-11-09 19:57

var
a:array[1..100] of longint;
n,i,tot:longint;
ans:real;
procedure sort(l,r: longint);
var
i,j,x,y: longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-1;
end;
until i>j;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end;
begin
readln(n);
for i:=1 to n do read(a[i]);
sort(1,n);
tot:=0;
for i:=2 to n-1 do inc(tot,a[i]);
ans:=tot/(n-2);
writeln(ans:0:2);
end.

热心网友 时间:2024-11-09 19:54

var
a:array[1..100] of longint;
n,i,tot:longint;
ans:real;
procedure sort(l,r: longint);
var
i,j,x,y: longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-1;
end;
until i>j;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end;
begin
readln(n);
for i:=1 to n do read(a[i]);
sort(1,n);
tot:=0;
for i:=2 to n-1 do inc(tot,a[i]);
ans:=tot/(n-2);
writeln(ans:0:2);
end.
声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。
E-MAIL:11247931@qq.com
Top