25.10.2010, 22:51
|
|
Эксперт
|
|
Регистрация: 19.03.2009
Сообщения: 1,261
Репутация: 45834
|
|
Коряво, но в учебных целях пойдет:
PHP код:
procedure TForm1.Button2Click(Sender: TObject);
var
a,b,c,d,x1,x2,x11,x12,x21,x22:real;
begin
if (edit1.text='')or(edit2.text='')or(edit3.text='') then
begin
ShowMessage ('Где данные?)');
end
else
begin
a:=strtofloat(edit1.text);
b:=strtofloat(edit2.text);
c:=strtofloat(edit3.text);
d:=b*b-4*a*c;
if d>0 then
begin
x1:=(-b+sqrt(d))/(2*a);
x2:=(-b-sqrt(d))/(2*a);
memo1.Lines.clear;
if x1>0 then
begin
x11:=-sqrt(x1);
x12:=sqrt(x1);
memo1.Lines.Add('x11 = '+floattostr(x11));
memo1.Lines.Add('x12 = '+floattostr(x12));
label2.Caption:='Проверка №11 : '+floattostr(x11*x11*x11*x11*a+b*x11*x11+c)+' = 0;';
label3.Caption:='Проверка №12 : '+floattostr(x12*x12*x12*x12*a+b*x12*x12+c)+' = 0;';
end;
if x2>0 then
begin
x21:=-sqrt(x2);
x22:=sqrt(x2);
memo1.Lines.Add('x21 = '+floattostr(x21));
memo1.Lines.Add('x22 = '+floattostr(x22));
label4.Caption:='Проверка №21 : '+floattostr(x21*x21*x21*x21*a+b*x21*x21+c)+' = 0;';
label5.Caption:='Проверка №22 : '+floattostr(x22*x22*x22*x22*a+b*x22*x22+c)+' = 0;';
end;
end
else
begin
label1.Caption:='d<0!';
label2.Caption:='';
label3.Caption:='';
label4.Caption:='';
label5.Caption:='';
end;
end;
end;
|