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;
}
#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;
}
como puedo hacer necesito sumar una matriz mas un vector mas un punto... gracias
ResponderBorrarcomo seria este mismo programa para Borland c++.? si alguien sabe e hiciera el favor se lo agradecería.
ResponderBorrarMUCHAS GRACIAS POR COMPARTIR SU CONOCIMIENTO, SALUDOS
ResponderBorrarCOMO 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
ResponderBorrarla funcion int te quedaria bien
BorrarGracias
ResponderBorrarGracias!
ResponderBorraren c no lo tienen
ResponderBorrarlo tendras en c? porfa
ResponderBorraresta en c
ResponderBorrargracias
ResponderBorrarmuchas gracias
ResponderBorrar