📄 ssdf.pas
字号:
unit ssdf;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Label4: TLabel;
Edit4: TEdit;
Label5: TLabel;
Edit5: TEdit;
Label6: TLabel;
Edit6: TEdit;
Label7: TLabel;
Edit7: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
Const
N=6;
{$R *.dfm}
//根据参数s数组中存放的评分用来求选手的最后得分,并通过参数aver带回
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//该循环求最高得分和最低得分并把所有得分加起来
Begin
if max_s<s[i] then
max_s:=s[i];
if min_s>s[i] then
min_s:=s[i];
sum:=sum+s[i];
end;
aver:=(sum-min_s-max_s)/(N-2);//求平均分
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ssdf:real;
Scores:array[0..N-1] of 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;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
edit5.Text:='';
edit6.Text:='';
edit7.Text:='';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -