主题:请教~ 为什么会错
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
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 x,y,z:integer;
t:real;
begin
for x:=1 to 50 do
for y:=1 to 100 do
for z:=1 to 100-x-y do
begin
t:= 2*x+y+0.5*z;
if (t=100 and x+y+z=100) then //为什么这条语句是错的
edit1.Text:=inttostr(x);
edit2.Text:=inttostr(y) ;
edit3.Text:=inttostr(z);
end;
end;
end.
[em7]
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
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 x,y,z:integer;
t:real;
begin
for x:=1 to 50 do
for y:=1 to 100 do
for z:=1 to 100-x-y do
begin
t:= 2*x+y+0.5*z;
if (t=100 and x+y+z=100) then //为什么这条语句是错的
edit1.Text:=inttostr(x);
edit2.Text:=inttostr(y) ;
edit3.Text:=inttostr(z);
end;
end;
end.
[em7]