G
guifuli
Unregistered / Unconfirmed
GUEST, unregistred user!
const
n = 6
//常量(n代表裁判)
var
Scores:array[0..n-1] of real
//申明变量Scores为数组
procedure GetScore(s:array of real
var aver:real)
//定义过程体两个参数(传入、传出)
var
i:integer
max_s,min_s:real
sum:real
begin
sum := 0
max_s := s[0]
min_s := s[0]
for i := 0 to n - 1 do // 大家单步跟踪一下这里的i,肯定是由6到1,我在许多机器上试过,都是这样的,当然最后的结果是正确的
begin
if max_s < s then
max_s := s
if min_s > s then
min_s := s
sum := sum + s
end;
aver := (sum - min_s - max_s)/(n - 2)
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ssdf:real;
begin
scores[0] := StrToFloat(edit1.Text);
scores[1] := StrToFloat(edit2.Text);
scores[2] := StrToFloat(edit3.Text);
scores[3] := StrToFloat(edit4.Text);
scores[4] := StrToFloat(edit5.Text);
scores[5] := StrToFloat(edit6.Text);
GetScore(scores,ssdf)
edit7.Text := FloatToStr(ssdf);
end;
n = 6
//常量(n代表裁判)
var
Scores:array[0..n-1] of real
//申明变量Scores为数组
procedure GetScore(s:array of real
var aver:real)
//定义过程体两个参数(传入、传出)
var
i:integer
max_s,min_s:real
sum:real
begin
sum := 0
max_s := s[0]
min_s := s[0]
for i := 0 to n - 1 do // 大家单步跟踪一下这里的i,肯定是由6到1,我在许多机器上试过,都是这样的,当然最后的结果是正确的
begin
if max_s < s then
max_s := s
if min_s > s then
min_s := s
sum := sum + s
end;
aver := (sum - min_s - max_s)/(n - 2)
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ssdf:real;
begin
scores[0] := StrToFloat(edit1.Text);
scores[1] := StrToFloat(edit2.Text);
scores[2] := StrToFloat(edit3.Text);
scores[3] := StrToFloat(edit4.Text);
scores[4] := StrToFloat(edit5.Text);
scores[5] := StrToFloat(edit6.Text);
GetScore(scores,ssdf)
edit7.Text := FloatToStr(ssdf);
end;