Suma de dos matrices

Suma de dos matrices de mxn

#include<iostream>
using namespace std;
int main(){
int m,n;
cout<<"Suma de matrices mxn"<<endl;
cout<<"Ingrese m: ";
cin>>m;
cout<<"Ingrese n: ";
cin>>n;
cout<<"***********"<<endl;
int mat1[m][n], mat2[m][n];

cout<<"Llenado de matriz 1"<<endl;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<"Ingrese numero: ";
cin>>mat1[i][j];
}
}
cout<<"\n";
cout<<"***********"<<endl;
cout<<"Llenado de matriz 2"<<endl;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<"Ingrese numero: ";
cin>>mat2[i][j];
}
}
cout<<"\n";
cout<<"La matriz 1 es: "<<endl;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<mat1[i][j]<<" ";

}
cout<<endl;

}
cout<<"\n";
cout<<"La matriz dos es: "<<endl;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<mat2[i][j]<<" ";

}
cout<<endl;

}

cout<<"\n";
cout<<"La suma de las dos matrices es:"<<endl;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<mat1[i][j]+mat2[i][j]<<" ";

}
cout<<endl;

}
return 0;
}

Comentarios

  1. como puedo hacer necesito sumar una matriz mas un vector mas un punto... gracias

    ResponderBorrar
  2. como seria este mismo programa para Borland c++.? si alguien sabe e hiciera el favor se lo agradecería.

    ResponderBorrar
  3. MUCHAS GRACIAS POR COMPARTIR SU CONOCIMIENTO, SALUDOS

    ResponderBorrar
  4. COMO QUEDARIA EN CASO QUE QUISIERA HACER USO DE FUNCIONES?? POR EJEMPLO UNA FUNCION PARA LLENAR LAS MATRICES Y OTRA PARA SUMARLAS AGRADECERE ME PUEDAS AYUDAS

    ResponderBorrar

Publicar un comentario

Entradas más populares de este blog

Numero capicua

Hallar el MCD para "n" números