Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Strict On
- Option Explicit On
- Imports System.Math
- Public Class Form1
- Sub f_reg(ByVal n1 As Integer, ByVal x1 As Single, ByVal h1 As Single)
- 'локальные переменные процедуры
- Dim i As Integer
- Dim y As Single
- Dim sum As Single
- Dim z1 As String = " N | "
- Dim z2 As String = " X | "
- Dim z3 As String = " Y | "
- Dim z As String = " "
- Dim z4 As String = "_____________"
- Dim max As Single = Single.MinValue
- sum = 0
- For i = 1 To n1
- y = CSng(3 * (Cos(2 * x1 + 1)) ^ 2)
- If y > max Then max = y
- z1 = z1 + Format(i, "000") + Space(6) + "|" + Space(2)
- z2 = z2 + Format(x1, "0.000") + Space(3) + "|" + Space(2)
- z3 = z3 + Format(y, "0.000") + Space(3) + "|" + Space(2)
- x1 = x1 + h1
- z4 = z4 + "____________"
- sum = sum + y
- Next i
- 'Вывод в ListBox
- ListBox1.Items.Add(z)
- ListBox1.Items.Add(z4)
- ListBox1.Items.Add(z1)
- ListBox1.Items.Add(z4)
- ListBox1.Items.Add(z)
- ListBox1.Items.Add(z2)
- ListBox1.Items.Add(z4)
- ListBox1.Items.Add(z)
- ListBox1.Items.Add(z3)
- ListBox1.Items.Add(z4)
- ListBox1.Items.Add(z)
- vivod(sum, TextBox4)
- vivod(max, TextBox5)
- End Sub
- 'кол-во итераций цикла
- Function f_zikl(ByVal a As Single, ByVal b As Single, ByVal h As Single) As Integer
- Return CInt(Fix((b - a) / h) + 1)
- End Function
- 'процедура ввода
- Sub vivod(ByVal W As Single, ByRef T As TextBox)
- T.Text = CStr(W)
- End Sub
- 'процедура вывода
- Function vvod(ByVal T As TextBox) As Single
- Return CSng(Val(T.Text))
- End Function
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim a As Single
- Dim b As Single
- Dim h As Single
- Dim x As Single
- Dim n As Integer
- a = vvod(TextBox1)
- b = vvod(TextBox2)
- h = vvod(TextBox3)
- n = f_zikl(a, b, h)
- x = a
- f_reg(n, x, h)
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- End
- End Sub
- Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
- TextBox1.Clear()
- TextBox2.Clear()
- TextBox3.Clear()
- TextBox4.Clear()
- TextBox5.Clear()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment