07-04-2018, 11:28 AM
الخدعة هي أني أدخلت القانون هكذا
فعرفته على شكل نص لا على شكل عدد مركب
PHP كود :
procedure TForm3.Button1Click(Sender: TObject);
var a,b,c,d,x1,x2 : real;
begin
resultat.Text := '';
a := strtofloat(edit1.text);
b := strtofloat(edit2.text);
c := strtofloat(edit3.text);
d := power(b,2) - 4*a*c;
x1 := -b/(2*a);
if d>=0 then
begin
x2 := sqrt(d)/(2*a);
resultat.Lines.Add('d=' + floattostr(d));
if d>0 then
begin
resultat.Lines.Add('x1=' + floattostr(x1 - x2));
resultat.Lines.Add('x2=' + floattostr(x1 + x2));
end;
if d=0 then
begin
resultat.Lines.Add('x=' + floattostr(x1));
end;
end;
if(d<0) then
begin
x2 := sqrt(-d)/(2*a);
resultat.Lines.Add('d=' + floattostr(d));
resultat.Lines.Add('x1=' + floattostr(x1) + '-' + floattostr(x2) + 'i');
resultat.Lines.Add('x2=' + floattostr(x1) + '+' + floattostr(x2) + 'i')
end;
chams derreche

