*
一元二次方程自动求解
举报
发布于:2022-11-01
更新于:2022-11-01
3
540
作品介绍:
问题4.编写程序:输入一元二次方程的系数a,b,c的值, 求解一元二次方程的根。
操作说明:
Private Sub root(x#, y#, z#) Dim t#, x1#, X2# t = y * y - 4 * x * z If t > 0 Then x1 = (-y + Sqr(t)) / (2 * x) X2 = (-y - Sqr(t)) / (2 * x) Cells(2, 1) = "实根" + "x1=" + Str(x1) + "," + "x2=" + Str(X2) Else x1 = -y / (2 * x): X2 = Sqr(Abs(t)) / (2 * x) Cells(3, 1) = "虚根" + "x1=" + Str(x1) + Str(t) + "i" + "," + "x2=" + Str(X2) + Str(t) + " i" End If End Sub