Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Ejemplos de Progrmacion
Ejemplos de Progrmacion
#include<iostream>
using namespace std;
int main()
{
int fA,cA,fB,cB,i,j,k;
float A[10][10], B[10][10],P[10][10];
//LECTURA DE DATOS PARA LA MATRIZ A
cout<<"\n\t Ing. el nro de filas de la matriz A: ";cin>>fA;
cout<<"\n\t Ing. el nro de columnas de la matriz A: ";cin>>cA;
cout<<"\t Ingrese los elementos de la matriz A:"<<endl;
for(i=0;i<fA;i=i+1)
{
for(j=0;j<cA;j=j+1)
{
cout<<"\t A["<<i+1<<","<<j+1<<"]=";cin>>A[i][j];
}
}
//LECTURA DE DATOS PARA LA MATRIZ B
cout<<"\n\t Ing. el nro de filas de la matriz B: ";cin>>fB;
cout<<"\n\t Ing. el nro de columnas de la matriz B: ";cin>>cB;
cout<<"\t Ingrese los elementos de la matriz B:"<<endl;
for(i=0;i<fB;i=i+1)
{
for(j=0;j<cB;j=j+1)
{
cout<<"\t B["<<i+1<<","<<j+1<<"]=";cin>>B[i][j];
}
}
if(fB==cA)
{//si es verdadero se puede muliplicar
for(i=0;i<fA;i=i+1)
{
for(j=0;j<cB;j=j+1)
{
P[i][j]=0;
for(k=0;k<cA;k=k+1)
{
P[i][j]=P[i][j]+A[i][k]*B[k][j];
}
}
}
//mostrar la matriz producto
cout<<"\n\tMATRIZ PRODUCTO"<<endl;
for(i=0;i<fA;i=i+1)
{
cout<<"\t";
for(j=0;j<cB;j=j+1)
{
cout<<P[i][j]<<" ";
}
cout<<endl;
}
}
else
{ cout<<"\tNO SE PUEDE MULTIPLICAR"<<endl;
}
}