Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int ai, aj, n, bi, bj;
  6. cout<<"Ingrese rango matriz: ";
  7. cin>>n;
  8. int matriza[n][n]; // Con esto obtegno el valor en posicion n,n
  9. int matrizb[n][n];
  10. int matrizc[n][n];
  11. double valordesuma, valortotalpos, valorpos;
  12.  
  13. // PRIMERA MATRIZ OBTENCION DATOS
  14. cout <<"MATRIZ A"<<endl;;
  15. for (ai=0; ai<n; ai=ai+1) //Por filas
  16. {
  17. cout <<"Ingrese fila "<<ai<<": ";
  18. for (aj=0;aj<n; aj=aj+1) // por columnas
  19. {
  20. // cout<<"Ingrese fila: ";
  21. cin>>valorpos;
  22. cout<<" ";
  23. matriza[ai][aj] = valorpos;
  24.  
  25. }
  26. }
  27. // SEGUNDA MATRIZ OBTENCION DATOS
  28. cout<<"MATRIZ B: "<<endl;
  29. for (bi=0; bi<n; bi=bi+1) //Por filas
  30. {
  31. cout <<"Ingrese fila "<<bi<<": ";
  32. for (bj=0;bj<n; bj=bj+1) // por columnas
  33. {
  34. // cout<<"Ingrese fila: ";
  35. cin>>valorpos;
  36. cout<<" ";
  37. matrizb[bi][bj] = valorpos;
  38.  
  39. }
  40. }
  41. // AHORA PROCEDEMOS A CALCULAR VALORES.
  42. for (aj=0; aj<n; aj=aj+1)
  43. {
  44. for (bi=0; bi<n;bi=bi+1)
  45. {
  46. if (bi==aj){
  47. valordesuma = matriza[ai][aj] * matrizb[bj][bi];
  48. valortotalpos = valortotalpos + valordesuma;
  49. matrizc[aj][bi] = valortotalpos;
  50. cout<<matrizc[aj][bi]<<endl;
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement