unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: 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
  year:Integer;
  flag:Boolean;
begin
  year:=StrtoInt(Edit1.text);  //将字符串转变为整型
  if year mod 4 = 0 then
  begin
      if year mod 100 =0  then
      begin
        if year mod 400=0 then
          flag:=true
        else
          flag:=false;
      end
      else
        flag:=true;
      end
  else
      flag:=false;
  if flag then
      Label2.Caption:=Edit1.text+'年是闰年。'
  else
      Label2.Caption:=Edit1.text+'年不是闰年。';

end;

end.
