Option Strict On
Module Module1
    Function f(ByVal x As Double, ByVal K As Double, ByVal p As Double) As Double
        Return p ^ 2 * (3 * x) ^ 3 * x - K * (2 + 2 * x) ^ 2 * (2 - 2 * x) ^ 2
    End Function
    Sub Main()
        Console.WriteLine(" Введите значение погрешности")
        Dim eps As Double = 10 ^ -6
        Console.WriteLine(" Введите значение рК")
        Dim K As Double = 10 ^ -6.88
        Dim p As Double = 10
        Dim a As Double = 0
        Dim b As Double = 1
        Dim c As Double
        Dim Fc As Double
        Dim Fa = f(a, K, p)
        Dim Fb As Double = f(b, K, p)
        Do While Math.Abs(b - a) > 2 * eps
            c = (b + a) / 2
            Fc = f(c, K, p)
            If Fa * Fc < 0 Then
                b = c
                Fb = Fc
            Else : a = c
                Fa = Fc
            End If
            If Fa <> f(a, K, p) Or Fb <> f(b, K, p) _
            Or Math.Sign(Fa) = Math.Sign(Fb) Then
                Console.WriteLine("   ERROR!!!")
            End If
        Loop
        c = (a + b) / 2
        Console.WriteLine(" При давлении {0} атм и рК = {1} ", p, -Math.Log10(K))
        Console.WriteLine(" было получено {0:f2}% C2H2", c * 100)
        Console.ReadLine()
    End Sub

End Module
