Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int ai, aj, n, bi, bj;
- cout<<"Ingrese rango matriz: ";
- cin>>n;
- int matriza[n][n]; // Con esto obtegno el valor en posicion n,n
- int matrizb[n][n];
- int matrizc[n][n];
- double valordesuma, valortotalpos, valorpos;
- // PRIMERA MATRIZ OBTENCION DATOS
- cout <<"MATRIZ A"<<endl;;
- for (ai=0; ai<n; ai=ai+1) //Por filas
- {
- cout <<"Ingrese fila "<<ai<<": ";
- for (aj=0;aj<n; aj=aj+1) // por columnas
- {
- // cout<<"Ingrese fila: ";
- cin>>valorpos;
- cout<<" ";
- matriza[ai][aj] = valorpos;
- }
- }
- // SEGUNDA MATRIZ OBTENCION DATOS
- cout<<"MATRIZ B: "<<endl;
- for (bi=0; bi<n; bi=bi+1) //Por filas
- {
- cout <<"Ingrese fila "<<bi<<": ";
- for (bj=0;bj<n; bj=bj+1) // por columnas
- {
- // cout<<"Ingrese fila: ";
- cin>>valorpos;
- cout<<" ";
- matrizb[bi][bj] = valorpos;
- }
- }
- // AHORA PROCEDEMOS A CALCULAR VALORES.
- for (aj=0; aj<n; aj=aj+1)
- {
- for (bi=0; bi<n;bi=bi+1)
- {
- if (bi==aj){
- valordesuma = matriza[ai][aj] * matrizb[bj][bi];
- valortotalpos = valortotalpos + valordesuma;
- matrizc[aj][bi] = valortotalpos;
- cout<<matrizc[aj][bi]<<endl;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement