- •VbCrLf)
- •Imports System.Math
- •Imports System.Math
- •InputVector(a, "a")
- •InputVector(b, "b")
- •Imports System.Math
- •InputVector(a, "a")
- •InputVector(b, "b")
- •InputVector(a, "a")
- •InputVector(b, "b")
- •VbCrLf)
- •VbCrLf)
- •VbCrLf)
- •InputVector(a, "a")
- •InputVector(b, "b")
- •InputVector(a, "a")
- •InputVector(b, "b")
- •InputVector(a, "a")
- •InputVector(b, "b")
InputVector(a, "a")
txtЖурнал.AppendText("Матрица a" & vbCrLf)
OutputVector(a, txtЖурнал)
InputVector(b, "b")
txtЖурнал.AppendText("Матрица b" & vbCrLf)
OutputVector(b, txtЖурнал)
Изм(a, za)
Изм(b, zb)
If za > zb Then
txtЖурнал.AppendText("В векотре А замен больше" & vbCrLf)
txtЖурнал.AppendText("Матрица a" & vbCrLf)
OutputVector(a, txtЖурнал)
End If
If za < zb Then
txtЖурнал.AppendText("В векторе В замен больше" & vbCrLf)
txtЖурнал.AppendText("Матрица b" & vbCrLf)
OutputVector(b, txtЖурнал)
End If
If za = zb Then
txtЖурнал.AppendText("Одинаковое колличество замен" & vbCrLf)
End If
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Label1.Click
End
End Sub
Private Sub Изм(ByRef x() As Single, ByRef числоЗамен As Single)
Dim i As Integer
For i = 1 To x.GetUpperBound(0)
If x(i) > 0 Then
x(i) = x(i) / i
числоЗамен = числоЗамен + 1
End If
Next
End Sub
Private Sub InputVector(ByRef x() As Single, Optional _
ByVal ArrayName As String = "элемент")
Dim i As Integer
For i = 1 To x.GetUpperBound(0)
x(i) = InputBox(ArrayName & "(" & i & ") = ?")
Next
End Sub
Private Sub OutputVector(ByVal x() As Single, _
ByVal y As TextBox)
Dim i As Integer
For i = 1 To x.GetUpperBound(0)
y.AppendText(x(i) & vbTab)
Next
y.AppendText(vbCrLf)
End Sub
End Class
Задача 2
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim vta, vtb As Boolean
Dim m, n As Integer
Dim ta() As Single, tb() As Single
TextBox1.Clear()
m = InputBox("Задайте количество елементов векторов TA и TB")
TextBox1.AppendText("Кол-во элементов векторов = " & m & vbCrLf)
ReDim ta(e)
ReDim tb(e)
InputVector(ta, "TA")
TextBox1.AppendText("Матрица TA" & vbCrLf)
OutputVector(ta, TextBox1)
InputVector(tb, "TB")
TextBox1.AppendText("Матрица TB" & vbCrLf)
OutputVector(tb, TextBox1)
For n = 1 To m - 1
If ta(m - 1) > ta(e) Then
vta = True
Else
vta = False
End If
Next
If vta = True Then
TextBox1.AppendText("Вектор TA упорядочен по убыванию" & vbCrLf)
Else
TextBox1.AppendText("Вектор TA не упорядочен по убыванию" & vbCrLf)
End If
For n = 1 To m - 1
If tb(m - 1) > tb(e) Then
vtb = True
Else
vtb = False
End If
Next
If vtb = True Then
TextBox1.AppendText("Вектор TB упорядочен по убыванию" & vbCrLf)
Else
TextBox1.AppendText("Вектор TB не упорядочен по убыванию" & vbCrLf)
End If
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Label1.Click
End
End Sub
Private Sub InputVector(ByRef x() As Single, Optional _
ByVal ArrayName As String = "элемент")
Dim i As Integer
For i = 1 To x.GetUpperBound(0)
x(i) = InputBox(ArrayName & "(" & i & ") = ?")
Next
End Sub
Private Sub OutputVector(ByVal x() As Single, _
ByVal y As TextBox)
Dim i As Integer
For i = 1 To x.GetUpperBound(0)
y.AppendText(x(i) & vbTab)
Next
y.AppendText(vbCrLf)
End Sub
End Class
Составьте функцию проверяющую, что все элементы одномерного массива имеют
значения, больше заданной величины. Используя эту функцию, определите для
двух заданных одномерных массивов А и В, у скольких из них значение всех
элементовбольшезаданнойвеличины h
Private Sub InputVector(ByRef x() As Single, Optional _
ByValArrayNameAs String = "элемент")
Dim iAs Integer
For i = 1 To x.GetUpperBound(0)
x(i) = InputBox(ArrayName& "(" &i& ") = ?")
Next
End Sub
Private Sub OutputVector(ByVal x() As Single, _
ByVal y AsTextBox)
Dim iAs Integer
For i = 1 To x.GetUpperBound(0)
y.AppendText(x(i) &vbTab)
Next
y.AppendText(vbCrLf)
End Sub
private function proverka( byref x()as single, byref h as Single) as Boolean
Dim I, k as Integer
Dim flag as boolean
K=0
Flag=true
I=1
While (I<x.getupperbound(0) and (flag=true)
Do if x(i) <h
Then flag=false
End if i=i+1
K=k+1
Loop
Next
proverka =flag
End function
Private Sub btnПуск_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnПуск.Click
Dim A(), B(), h as Single
Dim ma as Integer
txtЖурнал.Clear()
ma = InputBox _
("Задайтеколичествоэлементов в матрице ")
txtЖурнал.AppendText("ma = " & ma & _
vbTab& "na = " &na&vbCrLf)
RedimA(ma)
RedimB(mb)