Advertisement
sazid_iiuc

Untitled

Feb 17th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. main()
  5. {
  6.  
  7.     int i, j, k, l;
  8.     cout << "First matrix size(row column):" << endl;
  9.     cin >> i >> j;
  10.     cout << "Second matrix size(row column):" << endl;
  11.     cin >> k >> l;
  12.  
  13.     int a[i][j], b[k][l], c[j][l];
  14.     if (j == k)
  15.     {
  16.         cout << "First array:" << endl;
  17.         for (int n = 0; n < i; n++)
  18.         {
  19.             for (int m = 0; m < j; m++)
  20.             {
  21.                 cin >> a[n][m];
  22.             }
  23.         }
  24.  
  25.         cout << "Second array:" << endl;
  26.  
  27.         for (int n = 0; n < k; n++)
  28.         {
  29.             for (int m = 0; m < l; m++)
  30.             {
  31.                 cin >> b[m][n];
  32.             }
  33.         }
  34.         for (int t = 0; t < i; t++)
  35.         {
  36.             for (int u = 0; u < l; u++)
  37.             {
  38.                 c[t][u]=0;
  39.                 for (int v = 0; v < j; v++)
  40.                 {
  41.                     c[t][u] += a[t][v]*b[v][u];
  42.                 }
  43.  
  44.             }
  45.             cout << endl;
  46.         }
  47.  
  48.         for (int t = 0; t < j; t++)
  49.         {
  50.             for (int u = 0; u < l; u++)
  51.             {
  52.                 cout<<" "<<c[t][u];
  53.                
  54.             }
  55.             cout << endl;
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement