unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    procedure showSum(N: integer);
    function intSum(N: integer): integer;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var x:integer;
begin
  x:=StrToInt(Edit1.Text);
 showSum(x);
end;

function TForm1.intSum(N:integer):integer;
var
  Sum,i: Integer;
begin
  sum:=0;
  for i:=1 to N do
    Sum:=Sum+i;
  intSum:=Sum;
end;

procedure TForm1.showSum(N:integer);
var
  Sum,i: Integer;
begin
  sum:=0;
  for i:=1 to N do
    Sum:=Sum+i;
  ShowMessage('Sum='+inttostr(Sum));
end;

procedure TForm1.Button2Click(Sender: TObject);
var x:integer;
begin
  x:=StrToInt(Edit1.Text);
  Label2.caption:='1µ½'+Edit1.Text +'µÄÀÛ¼ÓºÍ='+inttostr(intSum(x));
end;

end.
