unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    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
  m,n,t,r:longword;
begin
  m:=strtoint(edit1.Text);
  n:=strtoint(edit2.Text);
  if m<=n then  begin
    t:=m;
    m:=n;
    n:=t;
  end;
  repeat
    r:=m mod n;
    m:=n;
    n:=r;
  until r=0;
  Label3.Caption:=edit1.Text+'与'+edit2.Text+'的最大公约数是：'+inttostr(m);
end;


end.
