unit FibonacciU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids, ExtCtrls;
type
TForm1 =
class(TForm)
Panel1: TPanel;
StringGrid1: TStringGrid;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[0,0]:='
Anzahl'; StringGrid1.Cells[0,1]:='
Ergebnis';
end;
procedure TForm1.Button1Click(Sender: TObject);
var zahl:
array of integer; anz,i :integer;
begin
Try anz:=StrToInt(Edit3.Text)
Except exit
end;
SetLength(zahl,anz);
Try zahl[1]:=StrToInt(Edit1.Text)
Except exit
end;
Try zahl[2]:=StrToInt(Edit2.Text)
Except exit
end;
StringGrid1.ColCount:=succ(anz);
If anz<=0
Then
Begin ShowMessage('
FEHLER...'); exit;
end;
For i:=2
to anz
do
StringGrid1.Cells[i,0]:=IntToStr(i);
zahl[i]:=zahl[i-1]+zahl[i-2];
StringGrid1.Cells[i,1]:=IntToStr(zahl[i]);
end;
end.