Задача следующая:
Анкета спортсмена, подавшего заявку на соревнование, состоит из его пола, роста, веса, размеров одежды и обуви. По заданной последовательности заявок найти средний размер обуви женщин, вес которых не превышает 50 кг.
Код ниже. Непонятно, как вычислить количество ячеек, на которое нужно разделить сумму, чтобы получить среднее арифметическое.
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[0, 0] := 'Пол';
StringGrid1.Cells[1, 0] := 'Рост';
StringGrid1.Cells[2, 0] := 'Вес';
StringGrid1.Cells[3, 0] := 'Размер одежды';
StringGrid1.Cells[4, 0] := 'Размер обуви';
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
Sum, Kol: integer;
Srob:Real;
begin
Srob:= 0;
Sum:=0;
for i := 1 to StringGrid1.RowCount-1 do
begin
if ((StringGrid1.Cells[0, i] = 'Жен') and (StrToInt(StringGrid1.Cells[2, i]) < 50)) then
Sum := (Sum + StrToInt(StringGrid1.Cells[4, i]));
Kol:= ???????????;
Srob:=Sum/Kol;
end;
if (Srob <> 0) then
ShowMessage('Средний размер обуви женщин равен ' + FloatToStr(Srob))
else
ShowMessage('Такой анкеты нет!');
end;
end.