5,390
社区成员
发帖
与我相关
我的任务
分享
unit Unit2;
interface
uses
SysUtils;
type
TCon = class
private
i, j : Integer;
public
function Runtest : string; overload;
function Runtest(Value : string) : string; overload;
end;
implementation
{ TCon }
function TCon.Runtest: string;
begin
i := 1;
while i <= 4 do
begin
j := i;
while j <= 5 do
begin
Result := Result + ' ' + IntToStr(j);
Inc(j);
end;
Inc(i);
end;
end;
function TCon.Runtest(Value: string): string;
begin
Result := Value;
i := 1;
while i <= 3 do
begin
j := i;
while j <= 5 do
begin
Result := Result + ' ' + IntToStr(j);
Inc(j);
end;
Inc(i);
end;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Unit2;
type
TForm1 = class(TForm)
Memo1: TMemo;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ACon : TCon;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ACon := TCon.Create;
Memo1.Lines.Text := Edit1.Text + ACon.Runtest;
ACon.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ACon := TCon.Create;
Memo1.Lines.Text := ACon.Runtest(Edit1.Text);
ACon.Free;
end;
{function & Button3}
function Runtest(Value : string) : string;
var
i, j : Integer;
begin
Result := Value;
i := 1;
while i <= 3 do
begin
j := i;
while j <= (5 + i) do
begin
Result := Result + ' ' + IntToStr(j);
Inc(j, 2);
end;
Inc(i);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Memo1.Lines.Text := Runtest(Edit1.Text);
end;
end.
{function & Button3}
function Runtest(Value : string) : string;
var
i, j : Integer;
begin
Result := Value;
i := 1;
while i <= 3 do
begin
j := i;
while j <= (5 + i) do
begin
Result := Result + ' ' + IntToStr(j);
Inc(j, 2);
end;
Inc(i);
end;
end;