unit Unit3;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Grids;
type
{ TForm3 }
TForm3 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
private
public
end;
var C : array[1..10] of integer;
i,kol,sum:integer; A,B:integer;
Form3: TForm3;
implementation
{$R *.lfm}
{ TForm3 }
procedure TForm3.Button1Click(Sender: TObject);
begin
A:=StrToInt(Edit1.Text);
B:=StrToInt(Edit2.Text);
sum := 0;
kol:=0;
for i := 1 to 10 do
begin
C[i] := random (100);
StringGrid1.Cells[i-1,0] := IntToStr(C[i]);
if (A <= C[i]) and (B>= C[i]) then inc (kol);
end;
Edit3.Text:=( IntToStr(kol)+ ' element between '+IntToStr(A)+' and '+IntToStr(B) );
if (C[i] >= A) and (C[i] <= B) then
sum := sum + C[i] ;
if sum > 0 then
Edit3.Text:=IntToStr(sum);
end;
end.