Delphi例子,求x的y次方是多少,也就是求一個x的N次方是多少,上學時候都學過,現在用Delphi來編碼實現,代碼同樣簡單,高手請繞行吧,Delphi新手請參考如下代碼:
01
unit
Unit1;
02
interface
03
uses
04
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
05
Dialogs, StdCtrls;
06
type
07
TForm1 =
class
(TForm)
08
Button1: TButton;
09
Edit1: TEdit;
10
Edit2: TEdit;
11
Edit3: TEdit;
12
Label1: TLabel;
13
Label2: TLabel;
14
procedure
Button1Click(Sender: TObject);
15
private
16
{ Private declarations }
17
public
18
{ Public declarations }
19
end
;
20
var
21
Form1: TForm1;
22
implementation
23
{$R *.dfm}
24
procedure
TForm1
.
Button1Click(Sender: TObject);
25
var
26
x,y :
Integer
;
27
begin
28
x := StrToInt(Edit1
.
Text);
29
y := StrToInt(Edit2
.
Text);
30
Edit3
.
Text := floatToStr(Exp(ln(x)*y));
31
end
;
32
end
.
Delphi求一個數的N次方,窗體程序,運行界面: