• Asignatura: Informática
  • Autor: mannydistribuciones5
  • hace 7 años

Realice un programa que calcule el producto de dos matrices cuadradas de 3x3.

COMO SE REALIZARIA ESTO EN DEV C++?

HELP

Respuestas

Respuesta dada por: JossBe
1

#include <iostream>

using namespace std;

#define FIL 100

#define COL 100

void leer(int, int, int[][COL], int[][COL]);

int main()

{

   int a1[FIL][COL], a2[FIL][COL], f, c;

   cout << "Ingrese el numero de filas:"; cin >> f;

   cout << "Ingrese el numero de columnas:"; cin >> c;

   leer(f, c, a1, a2);

}

//Creamos una función para leer los elementos  

void leer(int c, int f, int a1[FIL][COL], int a2[FIL][COL])

{

   int i, j;

   cout << endl << "Elementos de la Matriz A:" << endl;

   for (i = 0; i < f; i++)

   {

       for (j = 0; j < c; j++)

       {

           cout << "Leer Elemento [" << i << ";" << j << "]:";

           cin >> a1[i][j];

       }

   }

   for (i = 0; i < f; i++)

   {

       for (j = 0; j < c; j++)

           cout << a1[i][j] << " ";

       cout << endl;

   }

   cout << endl << "Elementos de la Matriz B:" << endl;

   for (i = 0; i < f; i++)

   {

       for (j = 0; j < c; j++)

       {

           cout << "Leer Elemento [" << i << "," << j << "]:"; cin >> a2[i][j];

       }

   }

   for (i = 0; i < f; i++)

   {

       for (j = 0; j < c; j++)

           cout << a2[i][j] << "  ";

       cout << endl;

   }

}

Con ese codigo podras capturar la dimesion de la matriz o si quires puedes definir de una vez la variable para que no capture los datos

Debes crear otra funcion para solo puedas sumarlas entre si, Espero te ayude

Preguntas similares