Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Шпоры по задачам.docx
Скачиваний:
2
Добавлен:
27.10.2018
Размер:
37.36 Кб
Скачать

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

Тут вы можете оставить комментарий к выбранному абзацу или сообщить об ошибке.

Оставленные комментарии видны всем.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]