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

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

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