procedure TForm1.Button1Click(Sender: TObject);
var
delta,m,n:real;
a,b,c:integer;
begin
a:=strtoint(edit1.Text);
b:=strtoint(edit2.Text);
c:=strtoint(edit3.Text);
if a<>0 then begin
delta:=b*b-4*a*c;
m:=-b/(2*a);
if delta>=0 then
if delta>0 then begin
n:=sqrt(delta)/(2*a);
lbldescription.Caption:='两个不相等实根';
lblx1.Caption:=floattostr(m+n);
lblx2.Caption:= floattostr(m-n);
end
else begin
lbldescription.Caption:='两个相等实根';
lblx1.Caption:=floattostr(m);
end
else begin
n:=sqrt(-delta)/(2*a);
lbldescription.Caption:='两个不相等复根';
lblx1.Caption:=floattostr(m)+'+'+floattostr(abs(n))+'i';
lblx2.Caption:=floattostr(m)+'-'+floattostr(abs(n))+'i';
end;
end
else
if b<>0 then begin
m:=-c/b;
lbldescription.Caption:='一个实根';
lblx1.Caption:=floattostr(m);
end
else
if c=0 then
lbldescription.Caption:='无穷实根'
else
lbldescription.Caption:='无解';
end;