unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
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 N:integer;
line:string;
procedure getdata(x:integer);
var i:integer;
temp:string;
begin
temp:=line;
for i:=-1 to 1do
begin
line:=temp;
line:=IntToStr(i)+line;
if x=1 then
begin
Memo1.Lines.Add(line);
line:='';
end
else
getdata(x-1);
end;
end;
begin
N:=5;
getdata(N);
end;
end.