kao,我的代码和apw的一样
原来我去一家公司笔试。他们让我做一个10的介乘。我就是这么写的
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
function f(n:integer):int64;
begin
if n<1 then
result:=1
else
result:=n*f(n-1);
end;
begin
edit2.Text:=IntToStr(f(StrToInt(edit1.Text)));
end;
end.