0% found this document useful (0 votes)
51 views2 pages

Matrices Programacion

This document contains code for performing operations on matrices in VB.NET. It defines subroutines for inputting the matrix size, randomly generating matrix values, displaying the matrix, calculating the main diagonal sum, calculating the product above the main diagonal, calculating the sum of squares below the main diagonal, finding the maximum value and its position, and counting how many times the maximum value occurs. The code takes a matrix as input, performs the defined operations on it using nested for loops, and outputs the results.

Uploaded by

Brighit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views2 pages

Matrices Programacion

This document contains code for performing operations on matrices in VB.NET. It defines subroutines for inputting the matrix size, randomly generating matrix values, displaying the matrix, calculating the main diagonal sum, calculating the product above the main diagonal, calculating the sum of squares below the main diagonal, finding the maximum value and its position, and counting how many times the maximum value occurs. The code takes a matrix as input, performs the defined operations on it using nested for loops, and outputs the results.

Uploaded by

Brighit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

OPERACIONES EN MATRICES

Module Module1
Sub Main()
Dim n, my As Integer
ingresar(n)
Dim m(n, n) As Integer
leer_matriz(m, n)
mostrar_matriz(m, n)
suma_principal(m, n)
prod_arriba(m, n)
suma_cuad_abajo(m, n)
numero_mayor(m, n, My)
repite(m, n, My)
End Sub
Sub ingresar(ByRef n As Integer)
Console.Write("Ingresa el orden de la matriz: ")
n = Console.ReadLine
End Sub
Sub leer_matriz(ByRef m(,) As Integer, ByVal n As Integer)
Randomize()
Dim a, b As Integer
For a = 0 To n - 1 Step 1
For b = 0 To n - 1 Step 1
m(a, b) = Rnd() * 10 + 1
Next
Next
End Sub
Sub mostrar_matriz(ByVal m(,) As Integer, ByVal n As Integer)
Dim a As Integer
Console.WriteLine()
For a = 0 To n - 1 Step 1
For b = 0 To n - 1 Step 1
Console.SetCursorPosition((5 * b) + 4, (3 * a) + 3)
Console.Write("{0}", m(a, b))
Next
Next
Console.ReadLine()
End Sub
Sub suma_principal(ByVal m(,) As Integer, ByVal n As Integer)
Dim c, s As Integer
s = 0
For c = 0 To n - 1 Step 1
s = s + m(c, c)
Next
Console.SetCursorPosition(0, (3 * n) + 3)
Console.Write("La suma de la diagonal principal es {0}", s)
Console.ReadLine()
End Sub
Sub prod_arriba(ByVal m(,) As Integer, ByVal n As Integer)
Dim f, c, p As Integer
p = 1
For f = 0 To n - 1 Step 1
For c = 0 To n - 1 Step 1
If (c > f) Then
p = p * m(f, c)
End If
Next
Next
Console.Write("La producto es de los elementos encima de la D. Principal
es : {0}", p)
Console.ReadLine()
End Sub
Sub suma_cuad_abajo(ByVal m(,) As Integer, ByVal n As Integer)
Dim f, c, s As Integer
s = 0
For f = 0 To n - 1 Step 1
For c = 0 To n - 1 Step 1
If (f > c) Then
s = s + Math.Pow(m(f, c), 2)
End If
Next
Next
Console.Write("La suma de cuadrados de los elementos por debajo de la D.P
es: {0}", s)
Console.ReadLine()
End Sub
Sub numero_mayor(ByVal m(,) As Integer, ByVal n As Integer, ByRef my As Integer)
Dim f, c, p1, p2 As Integer
my = 0
For f = 0 To n - 1 Step 1
For c = 0 To n - 1 Step 1
If (m(f, c) > my) Then
my = m(f, c)
p1 = f
p2 = c
End If
Next
Next
Console.Write("La nmero mayor es es {0}", my)
Console.ReadLine()
End Sub
Sub repite(ByVal m(,) As Integer, ByVal n As Integer, ByVal my As Integer)
Dim f, c, r As Integer
r = 0
For f = 0 To n - 1 Step 1
For c = 0 To n - 1 Step 1
If (my = m(f, c)) Then
r = r + 1
Console.Write("Se escuendra en la posicion: ({0},{1}) ", f + 1,
c + 1)
End If
Next
Next
Console.Write("Se repite {0} veces ", r)
Console.ReadLine()
End Sub
End Module

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy