using System;
namespace Practica5
{
internal class Punto
{
// Definir matrices
int[,] matrizA = {
{ 2, 4, 6 },
{ 8, 10, 2 },
{ 2, 4, 6 }
};
int[,] matrizB = {
{ 1, 3, 5 },
{ 7, 9, 11 },
{ 5, 3, 1 }
};
// Matriz resultado
int[,] matrizC = new int[3, 3];
// Método mostrar matrices A y B
public void MostrarMatrices()
{
Console.WriteLine("Matriz A:");
for (int filasI = 0; filasI < 3; filasI++)
{
for (int colsI = 0; colsI < 3; colsI++)
{
Console.Write(matrizA[filasI, colsI] + " ");
}
Console.WriteLine(); // salto por fila
}
Console.WriteLine("\nMatriz B:");
for (int filasJ = 0; filasJ < 3; filasJ++)
{
for (int colsJ = 0; colsJ < 3; colsJ++)
{
Console.Write(matrizB[filasJ, colsJ] + " ");
}
Console.WriteLine();
}
}
// Método calcular producto punto
public void ProductoPunto()
{
for (int i = 0; i < 3; i++) // filas de A
{
for (int j = 0; j < 3; j++) // columnas de B
{
for (int k = 0; k < 3; k++) // recorrido interno
{
matrizC[i, j] += matrizA[i, k] * matrizB[k, j];
}
}
}
}
// Método mostrar matriz resultado
public void MostrarC()
{
Console.WriteLine("\nMatriz C (resultado del producto punto):");
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(matrizC[i, j] + " ");
}
Console.WriteLine();
}
}
static void Main(string[] args)
{
Punto p = new Punto();
// Mostrar matrices originales
p.MostrarMatrices();
// Calcular producto punto
p.ProductoPunto();
// Mostrar matriz resultado
p.MostrarC();
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: