主题:我读不懂的一部分。望高手指教!
这是一个或许比较简单的程序吧但对于刚入门的我来说还是有点困难程序如下:求ax*x+b*x+c=0的根
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer
a = InputBox("请输入a的值")
b = InputBox("请输入b 的值")
c = InputBox("请输入c的值")
d = b * b - 4 * a * c
p = -b / (2 * a)
If d >= 0 Then
If d > 0 Then
r = Sqr(d)/(2 * a)
X1 = p + r
X2 = q - r
Else
X1 = p
X2 = p
End If
Print "x1="; X1, "x2="; X2
Else
q = Sqr(-d) / (2 * a)
Print "x1="; p; "+"; q; "i", "x2="; p; "-"; q; "i"
End If
我想知道r = Sqr(d)/(2 * a)和q = Sqr(-d) / (2 * a)
是什么意思啊?
还有Print "x1="; p; "+"; q; "i", "x2="; p; "-"; q; "i"
该怎么理解啊?
谢谢了,刚入门的我向大家真诚请教。
[em2]
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer
a = InputBox("请输入a的值")
b = InputBox("请输入b 的值")
c = InputBox("请输入c的值")
d = b * b - 4 * a * c
p = -b / (2 * a)
If d >= 0 Then
If d > 0 Then
r = Sqr(d)/(2 * a)
X1 = p + r
X2 = q - r
Else
X1 = p
X2 = p
End If
Print "x1="; X1, "x2="; X2
Else
q = Sqr(-d) / (2 * a)
Print "x1="; p; "+"; q; "i", "x2="; p; "-"; q; "i"
End If
我想知道r = Sqr(d)/(2 * a)和q = Sqr(-d) / (2 * a)
是什么意思啊?
还有Print "x1="; p; "+"; q; "i", "x2="; p; "-"; q; "i"
该怎么理解啊?
谢谢了,刚入门的我向大家真诚请教。
[em2]