求直角三角形的面积和周长,出现有关问题.不知道如何解决
求直角三角形的面积和周长,出现问题.不知道怎么解决.
var
a,b,c:real;
s,z:real;
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=strtofloat(edit3.Text);
if
(a+b>c) and (a+c>b) and (c+b>a)
then
begin
s:=(b+c)/2;
z:=a+b+c;
edit4.text:=floattostr(s);
edit5.text:=floattostr(z);
end;
else
MessageBox('对不起,输入的三角形边长有误,请从新输入');
end;
end.
-----------------------分割线----------------------
但总是出现 else那显示红底提示.
[错误] Unit1.pas(78): ';' not allowed before 'ELSE'
[错误] Unit1.pas(79): Incompatible types: 'HWND' and 'String'
[致命错误] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
还有经常运行运行着就 致命错误 Project1.dpr(5): Could not compile used unit 'Unit1.pas'
导致无法保存或无法正常打开.
刚接触delphi,望指点.
------解决方案--------------------
else之前不能有分号
MessageBox改为showmessage
var
a,b,c:real;
s,z:real;
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=strtofloat(edit3.Text);
if
(a+b>c) and (a+c>b) and (c+b>a)
then
begin
s:=(b+c)/2;
z:=a+b+c;
edit4.text:=floattostr(s);
edit5.text:=floattostr(z);
end;
else
MessageBox('对不起,输入的三角形边长有误,请从新输入');
end;
end.
-----------------------分割线----------------------
但总是出现 else那显示红底提示.
[错误] Unit1.pas(78): ';' not allowed before 'ELSE'
[错误] Unit1.pas(79): Incompatible types: 'HWND' and 'String'
[致命错误] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
还有经常运行运行着就 致命错误 Project1.dpr(5): Could not compile used unit 'Unit1.pas'
导致无法保存或无法正常打开.
刚接触delphi,望指点.
------解决方案--------------------
else之前不能有分号
MessageBox改为showmessage