Подскажите, пожалуйста, с решением задачи!
Заранее благодарю за помощь:)
Код:
Public Class Form1
Dim mMat() As String = {"Петров", "Сидоров", "Козлов", "Веселов", "Мартынов", "Пупков"}
Dim mFiz() As String = {"Петров", "Ветров", "Козлов", "Мочалов", "Мартынов", "Швондер", "Умников"}
Dim number_of_students As Integer = 0
Dim num_unicue_studenst As Integer = 0 'Количество "униткальных" студентов
Dim pStudents() As String 'массив студентов, участвующих в обеих олимпиадах
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mBigger() As String
Dim mSmaller() As String
If mMat.Length > mFiz.Length Then
mBigger = mMat
mSmaller = mFiz
Else
mBigger = mFiz
mSmaller = mMat
End If
For i As Integer = 0 To mBigger.Length - 1
For j As Integer = 0 To mSmaller.Length - 1
If mBigger(i) = mSmaller(j) Then
ReDim Preserve pStudents(number_of_students)
pStudents(number_of_students) = mSmaller(j)
number_of_students += 1
Exit For
End If
Next
Next
'ListBox2.Items.AddRange(pStudents)
'Считаем всех кроме тех кто в массиве pStudents
Dim no_mathes As Boolean = False 'Tru - нет совпадений
For i As Integer = 0 To mBigger.Length - 1
For j As Integer = 0 To pStudents.Length - 1
If mBigger(i) = pStudents(j) Then
no_mathes = False
Exit For
Else
no_mathes = True
End If
Next
If no_mathes = True Then
'ListBox1.Items.Add(mBigger(i))
num_unicue_studenst += 1
End If
Next
For i As Integer = 0 To mSmaller.Length - 1
For j As Integer = 0 To pStudents.Length - 1
If mSmaller(i) = pStudents(j) Then
no_mathes = False
Exit For
Else
no_mathes = True
End If
Next
If no_mathes = True Then
'ListBox1.Items.Add(mSmaller(i))
num_unicue_studenst += 1
End If
Next
MsgBox("Студентов, участвующих только в одной олимпиаде - " & num_unicue_studenst & " чел.")
End Sub
End Class
Dim mMat() As String = {"Петров", "Сидоров", "Козлов", "Веселов", "Мартынов", "Пупков"}
Dim mFiz() As String = {"Петров", "Ветров", "Козлов", "Мочалов", "Мартынов", "Швондер", "Умников"}
Dim number_of_students As Integer = 0
Dim num_unicue_studenst As Integer = 0 'Количество "униткальных" студентов
Dim pStudents() As String 'массив студентов, участвующих в обеих олимпиадах
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mBigger() As String
Dim mSmaller() As String
If mMat.Length > mFiz.Length Then
mBigger = mMat
mSmaller = mFiz
Else
mBigger = mFiz
mSmaller = mMat
End If
For i As Integer = 0 To mBigger.Length - 1
For j As Integer = 0 To mSmaller.Length - 1
If mBigger(i) = mSmaller(j) Then
ReDim Preserve pStudents(number_of_students)
pStudents(number_of_students) = mSmaller(j)
number_of_students += 1
Exit For
End If
Next
Next
'ListBox2.Items.AddRange(pStudents)
'Считаем всех кроме тех кто в массиве pStudents
Dim no_mathes As Boolean = False 'Tru - нет совпадений
For i As Integer = 0 To mBigger.Length - 1
For j As Integer = 0 To pStudents.Length - 1
If mBigger(i) = pStudents(j) Then
no_mathes = False
Exit For
Else
no_mathes = True
End If
Next
If no_mathes = True Then
'ListBox1.Items.Add(mBigger(i))
num_unicue_studenst += 1
End If
Next
For i As Integer = 0 To mSmaller.Length - 1
For j As Integer = 0 To pStudents.Length - 1
If mSmaller(i) = pStudents(j) Then
no_mathes = False
Exit For
Else
no_mathes = True
End If
Next
If no_mathes = True Then
'ListBox1.Items.Add(mSmaller(i))
num_unicue_studenst += 1
End If
Next
MsgBox("Студентов, участвующих только в одной олимпиаде - " & num_unicue_studenst & " чел.")
End Sub
End Class
спасибо)