本帖最后由 kingzkl 于 2023-6-28 09:28 编辑
[Delphi] 纯文本查看 复制代码 unit MainForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function Add(a, b, c, d, e, f: Integer): Integer;
var
sum, tempa, tempb, tempc, tempd, tempe, tempf: Integer;
begin
sum := 0;
tempa := a * 1;
tempb := b * 2;
tempc := c * 3;
tempd := d * 4;
tempe := e * 5;
tempf := f * 6;
sum := tempa + tempb + tempc + tempd + tempe + tempf;
Result := sum;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
a, b, c, d, e, f, sum: Integer;
begin
a := 1;
b := 2;
c := 3;
d := 4;
e := 5;
f := 6;
sum := Add(a, b, c, d, e, f);
ShowMessage('Sum = ' + IntToStr(sum));
end;
end.
|