El siguiente progroma hace la operacion basicas de los conjuntos union ,intercepcion,diferente
Este Programa esta realizado en .NET es un vector
Public Class Matematica_Conjuntos
Dim c As Object
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
c = New Conjuntos(conjA, conjB, conjC)
c.union()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
c.interseccion()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
c.diferencia()
End Sub
End Class
El siguiente codigo se hace en el Modulo llamado Conjuntos
Public Class Conjuntos
Private conjA As ListBox
Private conjB As ListBox
Private conjC As ListBox
Public Sub New(ByVal CA As ListBox, ByVal CB As ListBox, ByVal CC As ListBox)
conjA = CA
conjB = CB
conjC = CC
End Sub
Public Sub union()
conjC.Items.Clear()
For i = 0 To conjA.Items.Count - 1
conjC.Items.Add(conjA.Items.Item(i))
Next
For j = 0 To conjB.Items.Count - 1
conjC.Items.Add(conjB.Items.Item(j))
Next
End Sub
Public Sub interseccion()
conjC.Items.Clear()
For i = 0 To conjA.Items.Count - 1
For j = 0 To conjB.Items.Count - 1
If conjA.Items.Item(i) = conjB.Items.Item(j) Then
conjC.Items.Add(conjA.Items.Item(i))
End If
Next
Next
End Sub
Public Sub diferencia()
conjC.Items.Clear()
For i = 0 To conjA.Items.Count - 1
For j = 0 To conjB.Items.Count - 1
If conjA.Items.Item(i) <> conjB.Items.Item(j) Then
conjC.Items.Add(conjA.Items.Item(i))
End If
Next
Next
End Sub
End Class
Comentarios
Publicar un comentario