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

Publicar un comentario

Entradas más populares de este blog

Numero capicua

Invertir número

Hallar el dígito mayor de un numero