fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6.  
  7. int n,i,j,t,k,A[50][50],B[50][50],C[50][50];
  8. cout<<"enter limit";
  9. cin>>n;
  10. cout<<"enter elements of first array::";
  11.  
  12. for(i=0;i<n;i++)
  13. {
  14. for(j=0;j<n;j++)
  15. {
  16. cin>>A[i][j];
  17. }
  18. }
  19.  
  20. for(i=0;i<n;i++)
  21. {
  22. for(j=0;j<n;j++)
  23. {
  24. cin>>B[i][j];}}
  25. for(i=0;i<n;i++)
  26. {
  27. for(j=0;j<n;j++)
  28. {
  29. int v=0;
  30. for(k=0;k<n;k++)
  31. {
  32. v=v+(A[i][k]*B[k][j]);
  33. }
  34. C[i][j]=v;
  35. }
  36. }
  37.  
  38. for(i=0;i<n;i++)
  39. {
  40. for(j=0;j<n;j++)
  41. {
  42. cout<<C[i][j]<<"\t";
  43. }}
  44. return 0;
  45.  
  46. }
  47.  
Success #stdin #stdout 0s 4400KB
stdin
2
1
2
3
4
1
2
3
4
stdout
enter limitenter elements of first array::7	10	15	22