06-04-2018, 08:24 PM (آخر تعديل لهذه المشاركة: 06-04-2018, 08:35 PM بواسطة chamsderreche.)
السلام عليكم ، يجب عليكم لحل التمرين صنع برنامج يقوم بحل المعادلات من الدرجة الأولى والثانية حسب اختيار المستخدم ، شرط أن يحل المعادلات من الدرجة الثانية حتى و لو كانت الحلول في مجموعة الأعداد العقدية أو المركبة C ،مثل الملف المرفق والله ولي التوفيق
آسف نسيت ، مدة التمرين يوم واحد
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;