求:QB解一元二次不等式
qbasic吧
全部回复
仅看楼主
level 2
cyycoish 楼主
求:QB解一元二次不等式
2010年02月15日 17点02分 1
level 2
cyycoish 楼主
我有一种解法可惜太繁琐,而且无穷号只能用“%”号替代
且不等式格式只限于ax^2+bx+c > < >= <= 0
求更完美的解法。
Rem "SQIWOU [Version 2.0] <Created by CYy 20100209>"
Dim a
Dim b
Dim c
Dim d
Dim g
Dim x
Dim y
Print ""
Print " ##############################################################################"
Print " #                                                                             #"
Print " #                                  SQIWOU 2.0                                  #"
Print " #                           Created by CYy 20100209                            #"
Print " #                           a*x^2+b*x+c{> < >= <=}0                            #"
Print " #                                                                             #"
Print " ##############################################################################"
Print ""
Print "                      If you want to exit,please input 0."
Print "                     If you want to continue,please input 1."
Input i
Do While i <> 0
Print ""
Print "Please Input a,b,c ."
Input a,b,c
Print ""
Print "Please Input the operating symbol {d}"

2010年02月15日 17点02分 2
level 2
cyycoish 楼主
Print "If you Do Not know {d},"
Print "Please Input 0."
Input d
g = (b ^ 2 -   4 * a * c)
If g >= 0 Then
   x = (-b + sqr(g)) / (a * 2)
   y = (-b - sqr(g)) / (a * 2)
   If a <> 0 Then
    If d = 0 Then
     Print " 1:> 2:< 3:>= 4:<= "
     Print "Please input d again."
     Input d
    End If
    Print ""
    If a > 0 Then
     If x<>Y Then
      Select Case d
          Case 1
           Print "Answer:"
           Print " X belongs to (-%,"; y; ")U("; x; ",+%)"
          Case 2
           Print "Answer:"
           Print " X belongs to ("; y; ","; x; ")"
          Case 3
           Print "Answer:"
           Print " X belongs to (-%,"; y; "]U["; x; ",+%)"
          Case 4
           Print "Answer:"
           Print " X belongs to ["; y; ","; x; "]"
          Case Else
              Print "D was wromg again!!"
         End Select
         Else
          Select Case d
              Case 1
               Print "Answer:"
               Print " X belongs to (-%,0)U(0,+%)"
              Case 2
               Print "Answer:"
               Print " X belongs to the empty set."
              Case 3
               Print "Answer:"
               Print " X belongs to R"
              Case 4

2010年02月15日 17点02分 3
level 2
cyycoish 楼主
               Print "Answer:"
               Print " X belongs to {"; x; "}."
              Case Else
               Print "D was wromg again!!"
          End Select
      End If
    Else
     If x <> y Then
         Select Case d
          Case 1
           Print "Answer:"
           Print " X belongs to ("; y; ","; x; ")"
          Case 2
           Print "Answer:"
           Print " X belongs to (-%,"; y; ")U("; x; ",+%)"
          Case 3
           Print "Answer:"
           Print " X belongs to ["; y; ","; x; "]"
       Case 4
        Print "Answer:"
        Print " X belongs to (-%,"; y; "]U["; x; ",+%)"
       Case Else
           Print "D was wromg again!!"
       End Select
     Else   
         Select Case d
          Case 1
           Print "Answer:"
           Print " X belongs to the empty set."
          Case 2
           Print "Answer:"
           Print " X belongs to (-%,0)U(0,+%)"
          Case 3
           Print "Answer:"
           Print " X belongs to {"; y; "}."
          Case 4
           Print "Answer:"
           Print " X belongs to R"
          Case Else
              Print "D was wromg again!!"
         End Select
     End If  
    End If
   Else
    Print "Wrong because A=0"
   End If
Else
   Print "Wrong because b^2-4*a*c<0"
End If
Print ""
Print "End of calculate."
Print "                      If you want to exit,please input 0."
Print "                     If you want to continue,please input 1."
Input i
Loop
2010年02月15日 17点02分 4
level 2
cyycoish 楼主
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
没人理我?????????????????????????????
2010年03月26日 13点03分 6
level 1
你真是太强悍了
2010年06月23日 07点06分 7
level 1
这。。。是一串的吗?属于同一个程序?
强!!!
2010年08月02日 06点08分 8
level 1
根本解不来啊,没完没了
2010年08月02日 06点08分 9
level 2
cyycoish 楼主
注意啦,从 rem 开始 到最后一个 loop 是一个整体
9楼的,你八成是只复制了2楼的内容
2010年08月04日 14点08分 10
1