一元二次方程ax^2+bx+c=0的解x VB怎么写?
题目
一元二次方程ax^2+bx+c=0的解x VB怎么写?
答案
Private Sub Command1_Click()
Dim a As Integer,b As Integer,c As Integer
Dim m As Integer,x1 As Integer,x2 As Integer
a = Text1.Text
b = Text2.Text
c = Text3.Text
m = b ^ 2 - 4 * a * c
If a = 0 Then
Print wrong
Else
Select Case m
Case Is > 0
x1 = (-b + Sqr(m) / (2 * a))
x2 = (-b - Sqr(m) / (2 * a))
Print "不相等的两根 x1=" & x1 & ",x2=" & x2
Case 0
x1 = x2 = (-b / (2 * a))
Print "相等的两根 x1=x2 =" & x1
Case Is < 0
Print "No Real"
End Select
End If
End Sub
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
最新试题
热门考点