Guest User

лаба

a guest
Dec 21st, 2015
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Strict On
  2. Option Explicit On
  3. Imports System.Math
  4.  
  5. Public Class Form1
  6.     Sub f_reg(ByVal n1 As Integer, ByVal x1 As Single, ByVal h1 As Single)
  7.         'локальные переменные процедуры
  8.        Dim i As Integer
  9.  
  10.         Dim y As Single
  11.         Dim sum As Single
  12.         Dim z1 As String = " N | "
  13.         Dim z2 As String = " X | "
  14.         Dim z3 As String = " Y | "
  15.         Dim z As String = " "
  16.         Dim z4 As String = "_____________"
  17.  
  18.  
  19.  
  20.  
  21.         Dim max As Single = Single.MinValue
  22.         sum = 0
  23.         For i = 1 To n1
  24.             y = CSng(3 * (Cos(2 * x1 + 1)) ^ 2)
  25.  
  26.  
  27.             If y > max Then max = y
  28.  
  29.             z1 = z1 + Format(i, "000") + Space(6) + "|" + Space(2)
  30.             z2 = z2 + Format(x1, "0.000") + Space(3) + "|" + Space(2)
  31.             z3 = z3 + Format(y, "0.000") + Space(3) + "|" + Space(2)
  32.             x1 = x1 + h1
  33.             z4 = z4 + "____________"
  34.             sum = sum + y
  35.  
  36.         Next i
  37.  
  38.         'Вывод в ListBox
  39.  
  40.         ListBox1.Items.Add(z)
  41.  
  42.         ListBox1.Items.Add(z4)
  43.         ListBox1.Items.Add(z1)
  44.         ListBox1.Items.Add(z4)
  45.  
  46.         ListBox1.Items.Add(z)
  47.         ListBox1.Items.Add(z2)
  48.         ListBox1.Items.Add(z4)
  49.  
  50.         ListBox1.Items.Add(z)
  51.         ListBox1.Items.Add(z3)
  52.         ListBox1.Items.Add(z4)
  53.  
  54.         ListBox1.Items.Add(z)
  55.  
  56.         vivod(sum, TextBox4)
  57.  
  58.  
  59.         vivod(max, TextBox5)
  60.  
  61.     End Sub
  62.     'кол-во итераций цикла
  63.    Function f_zikl(ByVal a As Single, ByVal b As Single, ByVal h As Single) As Integer
  64.  
  65.         Return CInt(Fix((b - a) / h) + 1)
  66.  
  67.     End Function
  68.  
  69.     'процедура ввода
  70.    Sub vivod(ByVal W As Single, ByRef T As TextBox)
  71.         T.Text = CStr(W)
  72.     End Sub
  73.  
  74.     'процедура вывода
  75.    Function vvod(ByVal T As TextBox) As Single
  76.         Return CSng(Val(T.Text))
  77.     End Function
  78.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  79.         Dim a As Single
  80.         Dim b As Single
  81.         Dim h As Single
  82.  
  83.         Dim x As Single
  84.  
  85.         Dim n As Integer
  86.  
  87.         a = vvod(TextBox1)
  88.         b = vvod(TextBox2)
  89.         h = vvod(TextBox3)
  90.  
  91.         n = f_zikl(a, b, h)
  92.  
  93.         x = a
  94.  
  95.         f_reg(n, x, h)
  96.  
  97.     End Sub
  98.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  99.         End
  100.     End Sub
  101.  
  102.     Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
  103.         TextBox1.Clear()
  104.         TextBox2.Clear()
  105.         TextBox3.Clear()
  106.         TextBox4.Clear()
  107.         TextBox5.Clear()
  108.  
  109.  
  110.  
  111.  
  112.     End Sub
  113. End Class
Advertisement
Add Comment
Please, Sign In to add comment