有谁会Delphi编程的 帮我编程求一元二次方程ax2 + bx + c = 0的全部根
有谁会Delphi编程的 帮我编程求一元二次方程ax2 + bx + c = 0的全部根
要求至少使用edit、label、groupbox或panel控件
实现基本功能,界面良好,有创新
发我邮箱:158020123@QQ.com
追问:来自手机问问你会这软件?请教你下、我搜好多了、愁
有谁会Delphi编程的 帮我编程求一元二次方程ax2 + bx + c = 0的全部根
要求至少使用edit、label、groupbox或panel控件
实现基本功能,界面良好,有创新
发我邮箱:158020123@QQ.com
追问:来自手机问问你会这软件?请教你下、我搜好多了、愁
答案:【源代码给你发到邮箱了】 接收了别忘记给分!Q46730312
代码如下:
unit Unit1;
inte易做图ce
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;type
myresult = record
res1: double;
res2: double;
end;implementation
{$R *.dfm}
function Myfun(a,b,c:double):myresult;
var
aa: myresult;
begin
if (b*b-4*a*c) >= 0 then
begin
aa.res1 := (-b + sqrt(b*b - 4*a*c))/(2*a);
aa.res2 := (-b - sqrt(b*b - 4*a*c))/(2*a);
end ;
Result := aa;
end;procedure TForm1.Button1Click(Sender: TObject);
var
a,b,c: double;
jg: myresult;
begin
if (Edit1.Text ='') or (Edit2.Text ='') or (Edit3.Text = '') then
begin
ShowMessage('A、B、C常量值不能为空!');
Exit;
end;Try
a := StrtoFloat(Trim(Edit1.Text ));
b := StrtoFloat(Trim(Edit2.Text ));
c := StrtoFloat(Trim(Edit3.Text ));
Except
ShowMessage('数据格式转换错误!');
End;Memo1.Lines.Clear ;
if (b*b-4*a*c) < 0 then
Memo1.Lines.Add('该方程无解!')
else begin
jg := Myfun(a,b,c);
Memo1.Lines.Add('该方程的解为:');
Memo1.Lines.Add(' X1 = ' + FloattoStr(jg.res1));
Memo1.Lines.Add(' X2 = ' + FloatToStr(jg.res2));
end;
end;end.
开口向上;x=C;顶点坐标为(0,C)不错! 呵呵