Advertisement
sherry_ahmos

Untitled

Feb 28th, 2022
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <cstdlib>
  4. #include <bits/stdc++.h>
  5. #include <algorithm>
  6. #include <valarray>
  7.  
  8. using namespace std;
  9. #define ll long long
  10. void sherry()
  11. {
  12.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  13. #ifndef ONLINE_JUDGE
  14.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  15. #endif
  16. }
  17.  
  18. int main()
  19. {
  20.     sherry();
  21.     int x1, y1, x2, y2;
  22.     cin >> x1 >> y1;
  23.     int arr1[x1][y1];
  24.     for (int i = 0; i < x1; i++)
  25.     {
  26.         for (int j = 0; j < y1; j++)
  27.         {
  28.             cin >> arr1[i][j];
  29.         }
  30.     }
  31.     cin >> x2 >> y2;
  32.     int arr2[x2][y2];
  33.     for (int i = 0; i < x1; i++)
  34.     {
  35.         for (int j = 0; j < y1; j++)
  36.         {
  37.             cin >> arr2[i][j];
  38.         }
  39.     }
  40.     ll sum[x1][y2];
  41.     for (int i = 0; i < x1; i++)
  42.     {
  43.         for (int j = 0; j < y2; j++)
  44.         {
  45.             sum[i][j] = 0;
  46.             for (int x = 0; x < y1; x++)
  47.             {
  48.                 sum[i][j] += arr1[i][x] * arr2[x][j];
  49.             }
  50.             cout << sum[i][j] << " ";
  51.         }
  52.         cout << "\n";
  53.     }
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement