?? unit1.pas
字號:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Label4: TLabel;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function gongyue(a,b:integer):integer;
var
r,c:integer;
begin
if a>b then
begin
r:=a;
a:=b;
b:=r;
end;
r:=b mod a;
while r<>0 do
begin
a:=b;
b:=r;
r:=b mod a;
end;
result:=a;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var l:boolean;
begin
l:=(key<#48)or(key>#57);
if l then key:=#0;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
a,b:integer;
begin
if(edit1.Text='')then edit1.Text:='1';
if(edit2.Text='')then edit2.Text:='1';
a:=strtoint(edit1.Text);
b:=strtoint(edit2.Text);
edit3.Text:=inttostr(trunc(a/gongyue(a,b)));
edit4.Text:=inttostr(trunc(b/gongyue(a,b)));
a:=strtoint(edit3.Text);
b:=strtoint(edit4.Text);
if a mod b=0 then
begin
edit3.Text:=inttostr(trunc(a/b));
edit4.Text:='1';
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -