это снова я - немного не получается написать прогу - которую пишут свободно все 10-ти классники - вот условие: Наити произведение положительных элементов масива А={a[i]}, удовлетворяющих условию:
с<=a[i]<=d - где с и d задаем сами через Edit
вот что у меня получилось...
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
StringGrid1: TStringGrid;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
a: array [0..19] of intejer;
P, c, d: real;
i: intejer;
begin
randomize;
fot i:=0 to 19 do
begin
a[i]:=random(50--50+1)-50;
StringGrid1.Cells[0,i]:=inttoStr(a[i]);
end;
c:=StrtoInt(Edit1.Text);
d:=StrtoInt(Edit2.Text);
P:=1;
for i:=0 to 19 do
if (a[i]>0) and (a[i]>=c) and (a[i]<=d) then
P:=P*a[i];
Memo1.Lines.Add(FormatFloat('0.00',P);
end;
end.
Подскажите плиз...