Varv
							
								Новенький 
								
								 
								  Offline
								
								
								
								
							 
						 | 
						
							
								  | 
								
									
									 «  : 06-02-2011 10:30 »   | 
								
								 | 
							  
							 
							листинг:
  unit Unit1;
  interface
  uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,   Dialogs, Math, StdCtrls;
  type   TForm1 = class(TForm)     btn1: TButton;     lbl1: TLabel;     edt1: TEdit;     lbl2: TLabel;     edt2: TEdit;     lbl3: TLabel;     lbl4: TLabel;     lbl5: TLabel;     lbl6: TLabel;     lbl7: TLabel;     procedure btn1Click(Sender: TObject);     procedure edt1KeyPress(Sender: TObject; var Key: Char);     procedure edt2KeyPress(Sender: TObject; var Key: Char);   private     function factorial(N:Real):Real;     function chislsoch (x, y: Real): Real;     function engset(A,M,N: Real): Real;     { Private declarations }   public     { Public declarations }   end;
  var   Form1: TForm1;   i,N,M:Integer;   x,y,z,znam,chisl: Real; implementation
  {$R *.dfm}
  { TForm1 }
  function TForm1.factorial(N: Real): Real; begin
    if n = 1 then   factorial:= 1  else    factorial:= n*factorial(n-1);
  end;
 
  function TForm1.chislsoch(x, y: Real): Real; begin   chislsoch:= factorial(y)/(factorial(y-x)*factorial(x)); end;
  procedure TForm1.btn1Click(Sender: TObject); begin   if (Edt1.Text='') or (Edt2.Text='') then  lbl1.Caption:=('ââåäèòå çíà÷åíèå')
    else begin     N:=StrToInt(Edt1.Text);     M:=StrToInt(Edt2.Text);         if N>M then lbl1.Caption:=('íå âîçìîæíî,M>N')      else begin       Lbl1.Caption:=floattostr(factorial(N));       Lbl2.Caption:=floattostr(chislsoch(N,M));        Lbl7.Caption:=floattostr(engset(2,N,M));            end     end; end;
 
  procedure TForm1.edt1KeyPress(Sender: TObject; var Key: Char); begin    if not (key in['1'..'9',decimalseparator,#8]) then key:=#0;  //ðàçðåøàåì ââîäèòü òîëüêî ÷èñëà end;
  procedure TForm1.edt2KeyPress(Sender: TObject; var Key: Char); begin   if not (key in['2'..'9',decimalseparator,#8]) then key:=#0;  //ðàçðåøàåì ââîäèòü òîëüêî ÷èñëà end;
 
  function TForm1.engset(A,M,N: Real): Real; begin
    engset:= (chislsoch(N,M-1)*Power(A,N))/znam;    znam := 1;           for z:=1 to N do  begin
           znam:=znam+chislsoch(z,M-1)*Power(A,z);        end;
  end;
  end.
 
 
  ошибка в функции engset 
						 |