Файл: Шпоры по задачам.docx

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 25.08.2020

Просмотров: 119

Скачиваний: 4

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

21. Числа Фибоначи

Function Fk(ByVal n As Integer) As Integer

If (n = 1) Or (n = 2) Then

Fk = 1

Else : Fk = Fk(n - 1) + Fk(n - 2)

End If

End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim n, r As Integer

n = Val(TextBox1.Text)

If n < 100 Then

r = Fk(n)

TextBox2.Text = Str(r)

Else : MessageBox.Show("Введите меньшее n")

End If

End Sub




22. Отриц. элем. массива и их индексы.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click


Dim n, i As Integer

n = Val(TextBox1.Text)

Dim A(n) As Integer

Dim Rnd = New Random()

ListBox1.Items.Clear()

For i = 0 To n - 1

A(i) = Rnd.Next(31) - 15

ListBox1.Items.Add(Convert.ToString(A(i)))

Next i

Dim count As Integer = 0

For i = 0 To n - 1

If A(i) < 0 Then

count = count + 1

ListBox2.Items.Add(Convert.ToString(i))

End If

Next i

ListBox2.Items.Add("Всего отрицатиельных элем. =" & Convert.ToString(count))

End Sub




23.Число соседств в массиве.

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim M() As Integer = {-5, 12, 44, -6, -8, -9, 56, 32, 12, 65, -45, 98, -2}

Dim count As Integer = 0

Dim i As Int16

For i = 0 To 11

If M(i) * M(i + 1) < 0 Then

count = count + 1

End If

Next i

ListBox2.Items.Add(Convert.ToString(count))

End Sub



24. Путь робота.

Imports System

Imports System.Windows.Forms

Imports System.Drawing

Imports System.IO


Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim pB1 As Graphics

Dim X(), Y() As Integer

Dim N As Integer = 1

Dim path As String = "input.txt" ' имя файла

Dim fileinfo = New FileInfo(path) ' объявляем новый экземпляр файла

Dim InProbel As Integer = 0

ListBox2.Items.Clear() ' очистка ListBox

Dim streamreader As StreamReader = fileinfo.OpenText() ' Открываем файл для чтения

Dim sText As String = "" ' Строка текста в файле

Dim p As String = " " ' Разделитель чисел (пробел)

sText = streamreader.ReadLine() ' Читаем строку из файла

Do

ReDim Preserve X(N), Y(N) ' Увеличиваем размер массива

InProbel = sText.IndexOf(p) 'Определяем место расположения символа p (пробела)

X(N) = Convert.ToUInt16(sText.Substring(0, InProbel)) 'Координата X от начала строки до пробела

Y(N) = Convert.ToUInt16(sText.Substring(InProbel + 1, sText.Length - InProbel - 1)) 'Координата Y после пробела до конца строки

ListBox2.Items.Add(Convert.ToString(X(N)) + " " + Convert.ToString(Y(N))) 'Запись в ListBox для контроля

N = N + 1 'Увеличение счетчика на 1

sText = streamreader.ReadLine()

Loop Until sText = ""

pB1 = PictureBox1.CreateGraphics()

Dim greenPen = New Pen(Color.Green)

Dim i As Integer

Dim X1 As Integer = X(1)

Dim Y1 As Integer = Y(1)

For i = 2 To N - 1

pB1.DrawLine(greenPen, X1, Y1, X(i), Y(i))

X1 = X(i)

Y1 = Y(i)

Next

End Sub
















25. График астроиды.

Imports System

Imports System.Windows.Forms

Imports System.Drawing

Imports System.IO


Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

Dim k As Integer

Dim r As Double

k = Val(TextBox1.Text)

Dim pB2 As Graphics

pB2 = PictureBox1.CreateGraphics()

pB2.Clear(Color.Blue)

Dim X0 As Integer = PictureBox1.Width / 2

Dim Y0 As Integer = PictureBox1.Height / 2

Dim penGraph As New Pen(Color.Red)

Dim X1, Y1, X2, Y2 As Integer

Dim a As Integer, ar, L, X, Y As Single

Dim R1 As Integer = 40

X1 = X0 + k

Y1 = Y0

For a = 1 To 360

ar = a * Math.PI / 180

r = Math.Cos(ar) ^ 2

X2 = X0 + k * r * Math.Cos(ar)

Y2 = Y0 - k * r * Math.Sin(ar)

pB2.DrawLine(penGraph, X1, Y1, X2, Y2)

X1 = X2

Y1 = Y2

Next

End Sub



26. Мухоморчики до края картинки.

Imports System

Imports System.Windows.Forms

Imports System.Drawing

Imports System.IO


Sub Mashroom(ByVal x As Integer, ByVal y As Integer, ByVal picG As Graphics, ByVal PenDraw As Pen)

picG = PictureBox1.CreateGraphics()

picG.DrawEllipse(Pens.Black, x, y, 10, 20)

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

Dim pB3 As Graphics

pB3 = PictureBox1.CreateGraphics()

pB3.Clear(Color.White)

Dim x, y As Integer

x = 0

y = 30

Do While x < PictureBox1.Width - 10

Mashroom(x, y, pB3, Pens.Aqua)

x = x + 20

Loop

End Sub



27. Усеч. четырехугольная пирамида.

Imports System

Imports System.Windows.Forms

Imports System.Drawing

Imports System.IO


Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

Dim x, y, a As Integer

Dim pB4 As Graphics

pB4 = PictureBox1.CreateGraphics()

x = Val(TextBox1.Text)

y = Val(TextBox2.Text)

a = Val(TextBox3.Text)

pB4.DrawLine(Pens.Black, x, y, x + a, y)

pB4.DrawLine(Pens.Black, x, y, x + Convert.ToInt16(a / 4), y - Convert.ToInt16(a / 2))

pB4.DrawLine(Pens.Black, x + a, y, x + a - Convert.ToInt16(a / 4), y - Convert.ToInt16(a / 2))

pB4.DrawLine(Pens.Black, x + Convert.ToInt16(a / 4), y - Convert.ToInt16(a / 2), x + a - Convert.ToInt16(a / 4), y - Convert.ToInt16(a / 2))

End Sub



40. 6 призеров и победитель.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim r(10) As Integer

Dim f(10) As Integer

Dim i, j, b, imax As Integer

For i = 1 To 10

f(i) = i

r(i) = Int(Rnd() * 100)

ListBox1.Items.Add(Convert.ToString(f(i)) & " - " & Convert.ToString(r(i)))

Next

For i = 1 To 7

imax = i

For j = i + 1 To 10

If r(j) > r(imax) Then

imax = j

End If

Next

b = r(i)

r(i) = r(imax)

r(imax) = b

b = f(i)

f(i) = f(imax)

f(imax) = b

ListBox2.Items.Add(Convert.ToString(f(i)) & " - " & Convert.ToString(r(i)))

Next

End Sub










39. Первый + второй = третий массивы.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim a(5) As Integer

Dim b(5) As Integer

Dim c(10) As Integer

Dim i, j, baf, imax As Integer

For i = 1 To 5

a(i) = Int(Rnd() * 100)

b(i) = Int(Rnd() * 100)

ListBox1.Items.Add(Convert.ToString(a(i)) & " - " & Convert.ToString(b(i)))

Next

For i = 1 To 5

c(i) = a(i)

Next

For i = 6 To 10

c(i) = b(i - 5)

Next

For i = 1 To 9

imax = i

For j = i + 1 To 10

If c(j) < c(imax) Then

imax = j

End If

Next

baf = c(i)

c(i) = c(imax)

c(imax) = baf

ListBox2.Items.Add(Convert.ToString(c(i)))

Next

ListBox2.Items.Add(Convert.ToString(c(10)))

End Sub



38. Разложение экспоненты.

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim mye, p As Double

Dim n, i As Integer

mye = 2

p = 1

n = Convert.ToInt16(TextBox1.Text)

For i = 2 To n

p = p * i

mye = mye + 1 / p

Next

ListBox1.Items.Add(Convert.ToString(mye))

End Sub



37. Мин и Мах элем. массива.

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim n, i As Integer

n = Convert.ToInt16(TextBox1.Text)

Dim a(n) As Integer

Dim imax, imin, b As Integer

For i = 1 To n

a(i) = Int(Rnd() * 100)

ListBox1.Items.Add(Convert.ToString(a(i)))

Next

imax = 1

imin = 1

For i = 2 To n

If a(i) > a(imax) Then

imax = i

End If

If a(i) < a(imin) Then

imin = i

End If

Next

b = a(imax)

a(imax) = a(imin)

a(imin) = b

For i = 1 To n

ListBox2.Items.Add(Convert.ToString(a(i)))

Next

End Sub



36. Разложение синуса.

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

Dim n, i As Integer

n = Convert.ToInt16(TextBox1.Text)

Dim x, p, f As Double

x = Convert.ToDouble(TextBox2.Text)

f = 1

p = 1

If (n <= 100) And (x <= 20) Then

For i = 1 To n

f = f * i

p = p * (1 + Math.Sin(x * i) / f)

Next

ListBox2.Items.Add(Convert.ToString(p))

Else : ListBox2.Items.Add("введите n <=100 и x <=20")

End If

End Sub



35. Мяч.

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

Dim a, b, p, h, k As Integer

Dim th As Double

a = Convert.ToInt16(TextBox1.Text)

b = Convert.ToInt16(TextBox2.Text)

h = Convert.ToInt16(TextBox3.Text)

p = Convert.ToInt16(TextBox4.Text)

k = 0

th = h

Do

k = k + 1

th = th * a / b

Loop While th >= p

ListBox2.Items.Add(Convert.ToString(k))

MessageBox.Show(Convert.ToString(k))

End Sub






34. Площадь и объем пирамиды/призмы.

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

Dim a, h As Integer

Dim S, v As Double

a = Convert.ToInt16(TextBox1.Text)

h = Convert.ToInt16(TextBox3.Text)

If RadioButton1.Checked = True Then

If CheckBox1.Checked = True Then

S = a ^ 2

ListBox2.Items.Add(Convert.ToString(S))

End If

If CheckBox2.Checked = True Then

v = (1 / 3) * a ^ 2 * h

ListBox2.Items.Add(Convert.ToString(v))

End If

Else

If CheckBox1.Checked = True Then

S = a ^ 2

ListBox2.Items.Add(Convert.ToString(S))

End If

If CheckBox2.Checked = True Then

v = a ^ 2 * h

ListBox2.Items.Add(Convert.ToString(v))

End If

End If

End Sub



33. Полиндромы.

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

Dim s As String

s = TextBox1.Text

Dim i, n As Integer

Dim f As Boolean

f = True

n = s.Length

For i = 0 To Int(n / 2) - 1

If s.Substring(i, 1) <> s.Substring(n - i - 1, 1) Then

f = False

End If

Next

If f = True Then

MessageBox.Show("yes")

Else : MessageBox.Show("no")

End If

End Sub


32. Значение функции (системы).

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

Dim x, y, xmax, xmin, h, i As Double

xmin = Convert.ToDouble(TextBox1.Text)

xmax = Convert.ToDouble(TextBox2.Text)

h = Convert.ToDouble(TextBox3.Text)

For i = xmin To xmax Step h

If (i <= 9) Then

If (i <> 5) And (i <> -5) Then

y = 1 / (25 - i ^ 2)

ListBox1.Items.Add("x= " & Convert.ToString(i) & "y= " & Convert.ToString(y))

Else : ListBox1.Items.Add("error")

End If

Else

If i > 16 Then

If Math.Sin(i) >= 0 Then

y = Math.Sqrt(Math.Sin(i))

ListBox1.Items.Add("x= " & Convert.ToString(i) & "y= " & Convert.ToString(y))

Else : ListBox1.Items.Add("error")

End If

End If

End If

Next

End Sub


24. Путь робота.

Imports System

Imports System.Windows.Forms

Imports System.Drawing

Imports System.IO


Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim pB1 As Graphics

Dim X(), Y() As Integer

Dim N As Integer = 1

Dim path As String = "input.txt" ' имя файла

Dim fileinfo = New FileInfo(path) ' объявляем новый экземпляр файла

Dim InProbel As Integer = 0

ListBox2.Items.Clear() ' очистка ListBox

Dim streamreader As StreamReader = fileinfo.OpenText() ' Открываем файл для чтения

Dim sText As String = "" ' Строка текста в файле

Dim p As String = " " ' Разделитель чисел (пробел)

sText = streamreader.ReadLine() ' Читаем строку из файла

Do

ReDim Preserve X(N), Y(N) ' Увеличиваем размер массива

InProbel = sText.IndexOf(p) 'Определяем место расположения символа p (пробела)

X(N) = Convert.ToUInt16(sText.Substring(0, InProbel)) 'Координата X от начала строки до пробела

Y(N) = Convert.ToUInt16(sText.Substring(InProbel + 1, sText.Length - InProbel - 1)) 'Координата Y после пробела до конца строки

ListBox2.Items.Add(Convert.ToString(X(N)) + " " + Convert.ToString(Y(N))) 'Запись в ListBox для контроля

N = N + 1 'Увеличение счетчика на 1

sText = streamreader.ReadLine()

Loop Until sText = ""

pB1 = PictureBox1.CreateGraphics()

Dim greenPen = New Pen(Color.Green)

Dim i As Integer

Dim X1 As Integer = X(1)

Dim Y1 As Integer = Y(1)

For i = 2 To N - 1

pB1.DrawLine(greenPen, X1, Y1, X(i), Y(i))

X1 = X(i)

Y1 = Y(i)

Next


21. Числа Фибоначи

Function Fk(ByVal n As Integer) As Integer

If (n = 1) Or (n = 2) Then

Fk = 1

Else : Fk = Fk(n - 1) + Fk(n - 2)

End If

End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim n, r As Integer

n = Val(TextBox1.Text)

If n < 100 Then

r = Fk(n)

TextBox2.Text = Str(r)

Else : MessageBox.Show("Введите меньшее n")

End If

End Sub




22. Отриц. элем. массива и их индексы.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click


Dim n, i As Integer

n = Val(TextBox1.Text)

Dim A(n) As Integer

Dim Rnd = New Random()

ListBox1.Items.Clear()

For i = 0 To n - 1

A(i) = Rnd.Next(31) - 15

ListBox1.Items.Add(Convert.ToString(A(i)))

Next i

Dim count As Integer = 0

For i = 0 To n - 1

If A(i) < 0 Then

count = count + 1

ListBox2.Items.Add(Convert.ToString(i))

End If

Next i

ListBox2.Items.Add("Всего отрицатиельных элем. =" & Convert.ToString(count))

End Sub




23.Число соседств в массиве.

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim M() As Integer = {-5, 12, 44, -6, -8, -9, 56, 32, 12, 65, -45, 98, -2}

Dim count As Integer = 0

Dim i As Int16

For i = 0 To 11

If M(i) * M(i + 1) < 0 Then

count = count + 1

End If

Next i

ListBox2.Items.Add(Convert.ToString(count))

End Sub




25. График астроиды.

Imports System

Imports System.Windows.Forms

Imports System.Drawing

Imports System.IO


Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

Dim k As Integer

Dim r As Double

k = Val(TextBox1.Text)

Dim pB2 As Graphics

pB2 = PictureBox1.CreateGraphics()

pB2.Clear(Color.Blue)

Dim X0 As Integer = PictureBox1.Width / 2

Dim Y0 As Integer = PictureBox1.Height / 2

Dim penGraph As New Pen(Color.Red)

Dim X1, Y1, X2, Y2 As Integer

Dim a As Integer, ar, L, X, Y As Single

Dim R1 As Integer = 40

X1 = X0 + k

Y1 = Y0

For a = 1 To 360

ar = a * Math.PI / 180

r = Math.Cos(ar) ^ 2

X2 = X0 + k * r * Math.Cos(ar)

Y2 = Y0 - k * r * Math.Sin(ar)

pB2.DrawLine(penGraph, X1, Y1, X2, Y2)

X1 = X2

Y1 = Y2

Next

End Sub



26. Мухоморчики до края картинки.

Imports System

Imports System.Windows.Forms

Imports System.Drawing

Imports System.IO


Sub Mashroom(ByVal x As Integer, ByVal y As Integer, ByVal picG As Graphics, ByVal PenDraw As Pen)

picG = PictureBox1.CreateGraphics()

picG.DrawEllipse(Pens.Black, x, y, 10, 20)

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

Dim pB3 As Graphics

pB3 = PictureBox1.CreateGraphics()

pB3.Clear(Color.White)

Dim x, y As Integer

x = 0

y = 30

Do While x < PictureBox1.Width - 10

Mashroom(x, y, pB3, Pens.Aqua)

x = x + 20

Loop

End Sub



27. Усеч. четырехугольная пирамида.

Imports System

Imports System.Windows.Forms

Imports System.Drawing

Imports System.IO


Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

Dim x, y, a As Integer

Dim pB4 As Graphics

pB4 = PictureBox1.CreateGraphics()

x = Val(TextBox1.Text)

y = Val(TextBox2.Text)

a = Val(TextBox3.Text)

pB4.DrawLine(Pens.Black, x, y, x + a, y)

pB4.DrawLine(Pens.Black, x, y, x + Convert.ToInt16(a / 4), y - Convert.ToInt16(a / 2))

pB4.DrawLine(Pens.Black, x + a, y, x + a - Convert.ToInt16(a / 4), y - Convert.ToInt16(a / 2))

pB4.DrawLine(Pens.Black, x + Convert.ToInt16(a / 4), y - Convert.ToInt16(a / 2), x + a - Convert.ToInt16(a / 4), y - Convert.ToInt16(a / 2))

End Sub



40. 6 призеров и победитель.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim r(10) As Integer

Dim f(10) As Integer

Dim i, j, b, imax As Integer

For i = 1 To 10

f(i) = i

r(i) = Int(Rnd() * 100)

ListBox1.Items.Add(Convert.ToString(f(i)) & " - " & Convert.ToString(r(i)))

Next

For i = 1 To 7

imax = i

For j = i + 1 To 10

If r(j) > r(imax) Then

imax = j

End If

Next

b = r(i)

r(i) = r(imax)

r(imax) = b

b = f(i)

f(i) = f(imax)

f(imax) = b

ListBox2.Items.Add(Convert.ToString(f(i)) & " - " & Convert.ToString(r(i)))

Next

End Sub



39. Первый + второй = третий массивы.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim a(5) As Integer

Dim b(5) As Integer

Dim c(10) As Integer

Dim i, j, baf, imax As Integer

For i = 1 To 5

a(i) = Int(Rnd() * 100)

b(i) = Int(Rnd() * 100)

ListBox1.Items.Add(Convert.ToString(a(i)) & " - " & Convert.ToString(b(i)))

Next

For i = 1 To 5

c(i) = a(i)

Next

For i = 6 To 10

c(i) = b(i - 5)

Next

For i = 1 To 9

imax = i

For j = i + 1 To 10

If c(j) < c(imax) Then

imax = j

End If

Next

baf = c(i)

c(i) = c(imax)

c(imax) = baf

ListBox2.Items.Add(Convert.ToString(c(i)))

Next

ListBox2.Items.Add(Convert.ToString(c(10)))

End Sub


38. Разложение экспоненты.

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim mye, p As Double

Dim n, i As Integer

mye = 2

p = 1

n = Convert.ToInt16(TextBox1.Text)

For i = 2 To n

p = p * i

mye = mye + 1 / p

Next

ListBox1.Items.Add(Convert.ToString(mye))

End Sub


35. Мяч.

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

Dim a, b, p, h, k As Integer

Dim th As Double

a = Convert.ToInt16(TextBox1.Text)

b = Convert.ToInt16(TextBox2.Text)

h = Convert.ToInt16(TextBox3.Text)

p = Convert.ToInt16(TextBox4.Text)

k = 0

th = h

Do

k = k + 1

th = th * a / b

Loop While th >= p

ListBox2.Items.Add(Convert.ToString(k))

MessageBox.Show(Convert.ToString(k))

End Sub

37. Мин и Мах элем. массива.

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim n, i As Integer

n = Convert.ToInt16(TextBox1.Text)

Dim a(n) As Integer

Dim imax, imin, b As Integer

For i = 1 To n

a(i) = Int(Rnd() * 100)

ListBox1.Items.Add(Convert.ToString(a(i)))

Next

imax = 1

imin = 1

For i = 2 To n

If a(i) > a(imax) Then

imax = i

End If

If a(i) < a(imin) Then

imin = i

End If

Next

b = a(imax)

a(imax) = a(imin)

a(imin) = b

For i = 1 To n

ListBox2.Items.Add(Convert.ToString(a(i)))

Next

End Sub


36. Разложение синуса.

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

Dim n, i As Integer

n = Convert.ToInt16(TextBox1.Text)

Dim x, p, f As Double

x = Convert.ToDouble(TextBox2.Text)

f = 1

p = 1

If (n <= 100) And (x <= 20) Then

For i = 1 To n

f = f * i

p = p * (1 + Math.Sin(x * i) / f)

Next

ListBox2.Items.Add(Convert.ToString(p))

Else : ListBox2.Items.Add("введите n <=100 и x <=20")

End If

End Sub


34. Площадь и объем пирамиды/призмы.

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

Dim a, h As Integer

Dim S, v As Double

a = Convert.ToInt16(TextBox1.Text)

h = Convert.ToInt16(TextBox3.Text)

If RadioButton1.Checked = True Then

If CheckBox1.Checked = True Then

S = a ^ 2

ListBox2.Items.Add(Convert.ToString(S))

End If

If CheckBox2.Checked = True Then

v = (1 / 3) * a ^ 2 * h

ListBox2.Items.Add(Convert.ToString(v))

End If

Else

If CheckBox1.Checked = True Then

S = a ^ 2

ListBox2.Items.Add(Convert.ToString(S))

End If

If CheckBox2.Checked = True Then

v = a ^ 2 * h

ListBox2.Items.Add(Convert.ToString(v))

End If

End If

End Sub


33. Полиндромы.

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

Dim s As String

s = TextBox1.Text

Dim i, n As Integer

Dim f As Boolean

f = True

n = s.Length

For i = 0 To Int(n / 2) - 1

If s.Substring(i, 1) <> s.Substring(n - i - 1, 1) Then

f = False

End If

Next

If f = True Then

MessageBox.Show("yes")

Else : MessageBox.Show("no")

End If

End Sub



32. Значение функции (системы).

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

Dim x, y, xmax, xmin, h, i As Double

xmin = Convert.ToDouble(TextBox1.Text)

xmax = Convert.ToDouble(TextBox2.Text)

h = Convert.ToDouble(TextBox3.Text)

For i = xmin To xmax Step h

If (i <= 9) Then

If (i <> 5) And (i <> -5) Then

y = 1 / (25 - i ^ 2)

ListBox1.Items.Add("x= " & Convert.ToString(i) & "y= " & Convert.ToString(y))

Else : ListBox1.Items.Add("error")

End If

Else

If i > 16 Then

If Math.Sin(i) >= 0 Then

y = Math.Sqrt(Math.Sin(i))

ListBox1.Items.Add("x= " & Convert.ToString(i) & "y= " & Convert.ToString(y))

Else : ListBox1.Items.Add("error")

End If

End If

End If

Next

End Sub