Você está na página 1de 4

Sub Main()

Console.Title = "MATRICES"
'Declaración de variables
Dim n As Integer 'filas
Dim m As Integer 'columnas
'Utilizamos el Do para no permitir valores negativos, ni ceros
Do
Console.Write("Ingrese el número de filas: ")
n = Console.ReadLine()
n -= 1 '
Console.Write("Ingrese el número de columnas: ")
m = Console.ReadLine()
m -= 1
If n >= 0 And m >= 0 Then
Exit Do
End If
If n < 1 Or m < 1 Then
Console.WriteLine("ERROR")
Console.WriteLine("Ingrese de nuevo")
Console.WriteLine()
Main()
End If
Loop
Console.WriteLine()
Dim iMatriz(n, m) As Integer
For i = 0 To n
For j = 0 To m
Console.Write("Ingrese el elemento {0}, {1} : ", i, j)
iMatriz(i, j) = Console.ReadLine()
Next
Console.WriteLine("│")
Next
For i = 0 To n
Dim s As String = " "
For j = 0 To m
s &= iMatriz(i, j)
s &= vbTab
Next
Console.WriteLine(s)
Next

If n <> m Then 'Imprimimos la matriz NO cuadrada


Console.WriteLine()
Console.WriteLine("La matriz NO es cuadrada, por lo tanto nose puede
definir sus propiedades")
Console.WriteLine("Su traspuesta es:")
Dim imt(m, n) As Integer
For i = 0 To n
For j = 0 To m
imt(j, i) = iMatriz(i, j)
Next
Next
For i = 0 To m
Dim s As String = " "
For j = 0 To n
s &= imt(i, j)
s &= vbTab
Next
Console.WriteLine(s)
Next
Else 'Imprimimos la matriz cuadrada
Console.WriteLine()
Console.WriteLine("La matriz SI es cuadrada, por lo tanto sus
propiedades son las siguientes:")
Console.WriteLine("PROPIEDADES:")
Console.WriteLine()
'Propiedades
Dim diagonal As Boolean = True
Dim identidad As Boolean = True
Dim superior As Boolean = True
Dim inferior As Boolean = True
Dim escalar As Boolean = True
Dim e As Integer
e = iMatriz(0, 0)
For i = 0 To n
For j = 0 To m
If i <> j Then
If i < j Then
If iMatriz(i, j) <> 0 Then
inferior = False
End If
Else
If iMatriz(i, j) <> 0 Then
superior = False
End If
End If
If iMatriz(i, j) <> 0 Then
diagonal = False
identidad = False
End If
Else
If iMatriz(i, j) <> 1 Then
identidad = False
End If
If e <> iMatriz(i, j) Then
escalar = False
End If
End If
Next
Next
If diagonal = True Then
Console.WriteLine("1. MATRIZ DIAGONAL: Si")
Else
Console.WriteLine("1. MATRIZ DIAGONAL: No")
End If
If identidad = True Then
Console.WriteLine("2. MATRIZ IDENTIDAD: Si")
Else
Console.WriteLine("2. MATRIZ IDENTIDAD: No")
End If
If escalar = True Then
Console.WriteLine("3. MATRIZ ESCALAR: Si")
Else
Console.WriteLine("3. MATRIZ ESCALAR: No")
End If
If superior = True Then
Console.WriteLine("4. MATRIZ TRIANGULAR SUPERIOR: Si")
Else
Console.WriteLine("4. MATRIZ TRIANGULAR SUPERIOR: No")
End If
If inferior = True Then
Console.WriteLine("5. MATRIZ TRIANGULAR INFERIOR: Si")
Else
Console.WriteLine("5. MATRIZ TRIANGULAR INFERIOR: No")
End If
Console.WriteLine()
Console.WriteLine("Su traspuesta es:")
For i = 0 To n
Dim ss As String = " "
For j = 0 To m
ss &= iMatriz(j, i)
ss &= vbTab
Next
Console.WriteLine(ss)
Next
Console.WriteLine()
Console.WriteLine("Su traspuesta negativo es:")
For i = 0 To n
Dim sss As String = " "
For j = 0 To m
sss &= -(iMatriz(j, i))
sss &= vbTab
Next
Console.WriteLine(sss)
Next
Console.WriteLine()
Dim simetrica As Boolean = True
Dim antisimetrica As Boolean = True
For i = 0 To n
For j = 0 To m
If iMatriz(i, j) <> iMatriz(j, i) Then
simetrica = False
End If
If i = j Then
If iMatriz(i, j) <> 0 Then
antisimetrica = False
End If
Else
If iMatriz(i, j) <> -(iMatriz(j, i)) Then
antisimetrica = False
End If
End If
Next
Next
If simetrica = True Then
Console.WriteLine("6. MATRIZ SIMÉTRICA: Si")
Else
Console.WriteLine("6. MATRIZ SIMÉTRICA: No")
End If
If antisimetrica = True Then
Console.WriteLine("7. MATRIZ ANTISIMÉTRICA: Si")
Else
Console.WriteLine("7. MATRIZ ANTISIMÉTRICA: No")
End If
End If
Console.ReadLine()
Main()

End Sub

Você também pode gostar