Académique Documents
Professionnel Documents
Culture Documents
Practica Nº 15
Índice
1. Marco Teórico
CODIGO
Public Class Form1
Dim mat(,), fila, columna, aux, m(,) As Integer
Dim aleatorio As New Random
Dim f, c, con, vec(), vec2() As Integer
Dim mat1(,), f1, c1, x2, x3 As Integer
Dim aleat As New Random
f = TextBox1.Text
c = TextBox2.Text
ReDim mat(f, c)
matf(f, c, mat)
ascendente()
descendente()
primos()
End Sub
For i = 1 To f
For j = 1 To c
mat(i, j) = aleat.Next(1, 100)
Next
Next
For i = 1 To f
For j = 1 To c
mat(i, j) = mat(i, j)
Next
Next
con = 0
While con = 0
For i = 1 To f
For j = 1 To c
For k = 1 To f
For l = 1 To c
If i = k And j = l Then
Continue For
Else
If mat(i, j) = mat(k, l) Then
mat(i, j) = aleat.Next(1, 100)
con += 1
End If
End If
Next
Next
Next
Next
If con = 0 Then
con = 1
Else
con = 0
End If
End While
ListView1.View = View.Details
ListView1.Items.Clear()
ListView1.Columns.Clear()
For j = 1 To c
ListView1.Columns.Add(j.ToString, 70)
Next
For i = 1 To f
Dim lista As New ListViewItem
For j = 1 To c
If j = 1 Then
lista.Text = mat(i, j).ToString
ListView1.Items.Add(lista)
Else
lista.SubItems.Add(mat(i, j).ToString)
End If
Next
Next
Return m(q, r)
End Function
Sub ascendente()
For i = 1 To f
For j = 1 To c
mat(i, j) = mat(i, j)
Next
Next
For i = 1 To f
For j = 1 To c
For k = 1 To f
For l = 1 To c
If mat(i, j) < mat(k, l) Then
aux = mat(i, j)
mat(i, j) = mat(k, l)
mat(k, l) = aux
End If
Next
Next
Next
Next
ListView2.View = View.Details
ListView2.Items.Clear()
ListView2.Columns.Clear()
For j = 1 To c
ListView2.Columns.Add(j.ToString, 70)
Next
ListView2.Items.Add("ascendente")
For i = 1 To f
Dim lista As New ListViewItem
For j = 1 To c
If j = 1 Then
lista.Text = mat(i, j).ToString
ListView2.Items.Add(lista)
Else
lista.SubItems.Add(mat(i, j).ToString)
End If
Next
Next
End Sub
Sub descendente()
For i = 1 To f
For j = 1 To c
mat(i, j) = mat(i, j)
Next
Next
For i = 1 To f
For j = 1 To c
For k = 1 To f
For l = 1 To c
If mat(i, j) > mat(k, l) Then
aux = mat(i, j)
mat(i, j) = mat(k, l)
mat(k, l) = aux
End If
Next
Next
Next
Next
ListView2.View = View.Details
ListView2.Items.Add("Descendente")
For i = 1 To f
Dim lista As New ListViewItem
For j = 1 To c
If j = 1 Then
lista.Text = mat(i, j).ToString
ListView2.Items.Add(lista)
Else
lista.SubItems.Add(mat(i, j).ToString)
End If
Next
Next
End Sub
Sub primos()
ListBox1.Items.Clear()
For i = 1 To f
For j = 1 To c
mat(i, j) = mat(i, j)
Next
Next
For i = 1 To f
For j = 1 To c
con = 0
For k = 1 To mat(i, j)
If mat(i, j) Mod k = 0 Then
con += 1
End If
Next
If con = 2 Then
ListBox1.Items.Add(mat(i, j))
End If
Next
Next
End Sub
End Sub
Sub crear_matriz()
For i = 1 To f1
For j = 1 To c1
mat1(i, j) = aleat.Next(1, 100)
Next
Next
con = 0
While con = 0
For i = 1 To f1
For j = 1 To c1
For k = 1 To f1
For l = 1 To c1
If i = k And j = l Then
Continue For
Else
If mat1(i, j) = mat1(k, l) Then
mat1(i, j) = aleat.Next(1, 100)
con += 1
End If
End If
Next
Next
Next
Next
If con = 0 Then
con = 1
Else
con = 0
End If
End While
ListView3.View = View.Details
ListView3.Items.Clear()
ListView3.Columns.Clear()
For j = 1 To c1
ListView3.Columns.Add(j.ToString, 70)
Next
For i = 1 To f1
Dim lista As New ListViewItem
For j = 1 To c1
If j = 1 Then
lista.Text = mat1(i, j).ToString
ListView3.Items.Add(lista)
Else
lista.SubItems.Add(mat1(i, j).ToString)
End If
Next
Next
End Sub
For i = 1 To f1
For j = 1 To c1
If i = x3 Then
vec2(con5) = mat1(i, j)
con5 += 1
End If
Next
Next
For i = 1 To f1
For j = 1 To c1
If i = x2 Then
mat1(i, j) = vec2(con6)
con6 += 1
End If
Next
Next
For i = 1 To f1
For j = 1 To c1
If i = x3 Then
mat1(i, j) = vec(con7)
con7 += 1
End If
Next
Next
ListView4.View = View.Details
ListView4.Items.Clear()
ListView4.Columns.Clear()
For j = 1 To c1
ListView4.Columns.Add(j.ToString, 70)
Next
For i = 1 To f1
Dim lista As New ListViewItem
For j = 1 To c1
If j = 1 Then
lista.Text = mat1(i, j).ToString
ListView4.Items.Add(lista)
Else
lista.SubItems.Add(mat1(i, j).ToString)
End If
Next
Next
Return m1(q1, r1)
End Function
Private Function matf3(q2 As Integer, r2 As Integer, m2(,) As Integer) As
Integer
ListBox2.Items.Clear()
For i = 1 To f1
For j = 1 To c1
If mat1(i, j) Mod 5 = 0 Then
ListBox2.Items.Add(mat1(i, j))
End If
Next
Next
Diseño
2. Objetivos de la practica
Pc
Visual Basic
4. Procedimiento experimental
realizar 2 matrices:
5. Anexos