注册 登录
编程论坛 Delphi论坛

[求助]求算阶乘的程序

迷失星际 发布于 2004-11-11 13:44, 1333 次点击
在20以内输入,无法输入非数字
3 回复
#2
迷失星际2004-11-11 19:19

说说edit 和 button 里的代码就可以了,这里人气没这么低吧?

#3
知秋一页2004-11-12 11:25

你等一下,我看看,我的机子上面有没有,一会给你发上来!

#4
ask1234562010-01-15 18:15
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    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
  fac:integer;
  n,i:integer;
begin
  n:=strtoint(inputbox('输入','输入一个不太大的整数','10'));
  label1.Caption :=inttostr(n);
  fac:=1;
  for i:=n downto 2 do
  fac:=fac*i;
  label1.caption:=inttostr(n)+'!='+inttostr(fac);

end;

end.
1