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;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
private
public
end;
const N=10;
var k1,k2,i,sum:INTEGER;
D : array[1..N] of integer;
Form3: TForm3;
implementation
{$R *.lfm}
{ TForm3 }
procedure TForm3.Button1Click(Sender: TObject);
begin
k1:=StrToInt(Edit1.Text);
k2:=StrToInt(Edit2.Text);
begin
for i := 1 to 10 do D[i] := random (256);
//StringGrid1.Cells[i-1,0]:=FloatToStr(D[i])
end;
Begin
if (k1 > n) or (k1 < 1) then
Edit3.Text:=('error')
else if (k2 > n) or (k2 < 1) then
Edit3.Text:=('error') ;
end;
sum:= 0;
for i:= k1 to k2 do
sum:= sum + d[i];
end;
end.