Option Strict On Option Explicit On Imports System.Math Public Class Form1 Function vvod(ByVal T As TextBox) As Integer Return CInt(Val(T.Text)) End Function Sub vvod(ByVal y() As Single, ByVal n As Integer, ByRef ListBox1 As ListBox) Dim i As Integer Dim y2 As String y2 = "" For i = 0 To n y(i) = CSng(Val(InputBox("Введите значение y(" & Str(i) & ")"))) y2 = y2 + Format(y(i), "###.##" + Space(5)) Next ListBox1.Items.Add(y2) End Sub Function Count(ByVal y() As Single, ByVal n As Integer, ByRef s_geo As Single, ByRef t As Integer) As Integer Dim i, j As Integer Dim nearIndex As Integer = 0 Dim delta As Single Dim min As Single s_geo = 1 For i = 0 To n If y(i) > 0 Then s_geo = CSng((s_geo * y(i)) ^ (1 / n)) End If Next Dim p(0 To n) As Single p(0) = min For i = 1 To UBound(y) - 1 For j = 1 To n delta = Abs(s_geo - y(i)) p(j) = delta If p(j) < min Then p(j) = min End If Next Next i End Function Function vivod(ByVal Z As Double, ByVal T As TextBox) As Double T.Text = CStr(Z) End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim n As Integer Dim s_geo As Single Dim t As Integer n = vvod(TextBox1) - 1 Dim y(0 To n) As Single vvod(y, n, ListBox1) Count(y, n, s_geo, t) vivod(s_geo, TextBox2) vivod(t, TextBox3) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click, Button2.Click TextBox1.Clear() ListBox1.Items.Clear() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Application.Exit() End Sub End Class