r = 3: c1 = 1: c2 = 2 'cells ¦ì¸m
Cells(r, c1).Resize(, 3) = Array("x1", "x2", "f(x1)")
While x <= x2
ct = ct + 1
If Application.Median(f(x), 0, f(x + s)) = 0 Then
r = r + 1
Cells(r, c1).Resize(, 3) = Array(x, x + s, f(x)) 'Debug ¥Î
If Round(f(x), 12) = 0 Then
r = r + 1
Cells(r, c1) = "ªñ¦ü¸Ñ¡G" & x & " , " & f(x)
x = x + s
s = 1
Else
s = s / ss
End If
Else
x = x + s
End If
Wend
Cells(r + 1, c1) = "´`Àô¦¸¼Æ¡G" & ct
Cells(r + 2, c1) = "pºâ®É¶¡¡G" & Format(Timer - tm, "0.000")
End Sub§@ªÌ: ML089 ®É¶¡: 2021-10-23 16:32
Option Explicit
Sub ¤@¤¸¤@¤G¤T¥|¦¸¤èµ{¦¡_¹ê¼Æ¸Ñ()
Dim InB$, Q$, i&, x#, x1#, a#, a1#, a2#, b#, c#, s#, S0#, S1#, S2#, Y0#, Y1#
Dim P#, J$, T&, d&, Arr, st#, S3#, K$, K1$, K2$, Kb$, Kc$
InB = UCase(InputBox("½Ð¿é¤J¤èµ{¦¡ ¨Ò: X4-6X3+X2+2X+24=0", "½Ð¿é¤J", "2X4-4X3-3X2+7X-2=0"))
If (InB Like "*0" = False And InB Like "*#") Or InB Like "*X" Then InB = InB & "=0"
Q = InB: InB = Replace(InB, " ", "")
If InB Like "*X*=0" = False Or InB Like "*,*" Then T = -1: GoTo 777
If InB Like "X*" Then InB = "1" & InB
If InB Like "-X*" Then InB = "-1" & InB
InB = Replace(Replace(InB, "+X", "+1X"), "-X", "-1X")
InB = Replace(Replace(Replace(Replace(InB, "X4=", "X4+0="), _
"X3=", "X3+0="), "X2=", "X2+0="), "X1=", "X1+0=")
InB = Replace(Replace(Replace(Replace(InB, "+", ",+"), "-", ",-"), "=0", ",=,"), "X", ",X")
Arr = Split(InB, ",")
If InStr(",X4,X3,X2,X,", "," & Arr(1) & ",") = 0 Then T = -3: GoTo 777
For i = 0 To UBound(Arr)
If Arr(i) = "X4" Then a2 = Arr(i - 1)
If Arr(i) = "X3" Then a1 = Arr(i - 1)
If Arr(i) = "X2" Then a = Arr(i - 1)
If Arr(i) = "X" Then b = Arr(i - 1)
If Arr(i) = "=" Then c = Arr(i - 1)
Next
K = a: K1 = a1: K2 = a2: Kb = b: Kc = c:
If K & K1 & K2 & Kb & Kc Like "*0.*" Then T = -4: GoTo 777
T = 0: d = 26: S0 = -10001: S1 = 10001: S2 = S1: s = 0.5: st = s: P = 1
999
For x = S0 To S1 Step s
DoEvents
If s = st Then S3 = x
Y0 = a2 * x ^ 4 + a1 * x ^ 3 + a * x ^ 2 + b * x + c: x1 = x + s
Y1 = a2 * x1 ^ 4 + a1 * x1 ^ 3 + a * x1 ^ 2 + b * x1 + c
If Y0 = 0 Then
J = J & vbLf & "¹ê¼Æ¸ÑX = " & x: S0 = S3 + s: S1 = S2: GoTo 999
End If
If Y1 = Y0 Then S0 = x + st: S1 = S2: GoTo 999
P = Y0 * Y1
If Int(Abs(P * 10 ^ d)) = 0 Then
T = T + 1
If s <> st Then J = J & vbLf & "¹ê¼Æ¸ÑX = " & x1
s = st: S0 = S3 + s: S1 = S2: GoTo 999
End If
If Int(Abs(s * 10 ^ d)) = 0 Then P = 0
If P < 0 Then
S0 = x: S1 = S0 + s: s = s / 10: GoTo 999
ElseIf P > Abs(a2) + Abs(a1) + Abs(a) + Abs(b) + Abs(c) Then
S0 = x + st: S1 = S2: GoTo 999
End If
Next
777
If T > 0 Then
MsgBox Q & vbLf & J
ElseIf T = 0 Then
MsgBox Q & vbLf & vbLf & " X µL¹ê¼Æ¸Ñ!"
Else
MsgBox Q & vbLf & vbLf & " µLªk°õ¦æ!"
End If
End Sub§@ªÌ: ML089 ®É¶¡: 2021-10-25 21:49
'¥i¥H§R°£¤é´ú¸Õ¤u§@ªí
Sub Del_Sheet()
Dim MyBook As Workbook, sh As Worksheet
Set MyBook = ThisWorkbook
Application.DisplayAlerts = False '°±¤î¨t²ÎªºÄµ¥Ü
For Each sh In MyBook.Sheets
If sh.Name Like Day(Now()) & "_*" Then sh.Delete '§R°£·í¤é DD_*
Next
Application.DisplayAlerts = True '«ì´_¨t²ÎªºÄµ¥Ü
End Sub§@ªÌ: Andy2483 ®É¶¡: 2022-9-28 22:01