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;
相关文章
- NX二次开发-Block UI C++界面Object Color Picker(对象颜色拾取器)控件的获取(持续补充)
- 关于开源大模型(如 LLaMA、InternLM、Baichuan、DeepSeek、Qwen 等)二次开发或训练经验的关键点和概述
- (python)1求一元二次方程的解(10分)
- C++中的谓词(一元谓词 & 二元谓词)
- Java微信二次开发(六)
- Python_sklearn机器学习库学习笔记(一)_一元回归
- 微信小程序——仿jqueryValidate表单验证插件WxValidate的二次封装(一)
- java获取字符串某个标点第二次出现的位置,并截取这个标点后面的字符串
- oo第二次总结
- 抓取锁的sql语句-第二次修改